Skip to content

How should I retrieve the localization of the lines from its words #573

Answered by charlesmindee
ghost asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @hammadyounas2008,

you can use this snippet to display boxes on the source image:

from doctr.io import DocumentFile
from doctr.models import ocr_predictor

model = ocr_predictor(pretrained=True)
# PDF
doc = DocumentFile.from_pdf("path/to/your/doc.pdf").as_images()
# Analyze
result = model(doc)
result.show(doc)

If you want to display lines boxes and not just words boxes, you can go to utils/visualization.py and set words_only=False in the visualize_page function, it will display blocks and lines.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@ghost
Comment options

Comment options

You must be logged in to vote
1 reply
@fg-mindee
Comment options

Answer selected by fg-mindee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
module: io Related to doctr.io module: utils Related to doctr.utils
2 participants