Skip to content

How to get bboxes and respective texts, confidence scores like easyocr or paddleocr #29

Discussion options

You must be logged in to vote

Hi @saichandrareddy1 👋

Here is a detailed script to understand how you can get your required informations 🤗

If you like the repo feel free to give a ⭐

import requests
import cv2
import numpy as np

from onnxtr.io import DocumentFile
from onnxtr.models import ocr_predictor

# Fetch a example image
image_url = "https://huggingface.co/datasets/huggingfacejs/tasks/resolve/main/document-question-answering/document-question-answering-input.png"
bytes_data = requests.get(image_url).content


# Convert relative coordinates to absolute pixel values
def _to_absolute(geom, img_shape: tuple[int, int]) -> list[list[int]]:
    h, w = img_shape
    if len(geom) == 2:  # Assume straight pages = True -> […

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by felixdittrich92
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #26 on August 20, 2024 11:16.