Skip to content

How to run only detection model to get the bounding boxes. (Handwritten text) #1734

Answered by felixdittrich92
sanjay-nit asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @sanjay-nit 👋,
Sure the ocr_predictor instance is at the end only a wrapper around the detection_predictor / recognition_predictor and crop_orientation_predictor / page_orientation_predictor.

Here you go (example code):

import requests
import cv2
import numpy as np

from doctr.io import DocumentFile
from doctr.models import detection_predictor
from doctr.utils.geometry import detach_scores


# 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 -> [[xmin, ymin], [xmax, ymax]]
        (xmin, ymin), (xmax, ymax) = geom
        xmin, xmax = i…

Replies: 5 comments 16 replies

Comment options

You must be logged in to vote
2 replies
@sanjay-nit
Comment options

@felixdittrich92
Comment options

Answer selected by sanjay-nit
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
10 replies
@felixT2K
Comment options

@felixT2K
Comment options

@sanjay-nit
Comment options

@sanjay-nit
Comment options

@felixdittrich92
Comment options

Comment options

You must be logged in to vote
4 replies
@felixdittrich92
Comment options

@hanshupe007
Comment options

@felixdittrich92
Comment options

@felixdittrich92
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants