Skip to content

How to get or see the re-constructed page for a given input ? #446

Answered by fg-mindee
PrasannaVpk asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @PrasannaVpk 👋

If you mean the image synthesized from the model predictions, here is a snippet:

import matplotlib.pyplot as plt
from doctr.io import DocumentFile
from doctr.models import ocr_predictor
from doctr.utils.visualization import synthetize_page

model = ocr_predictor(pretrained=True)
# PDF
doc = DocumentFile.from_pdf("path/to/your/doc.pdf").as_images()
# Analyze
result = model(doc)
# Reconstructed the first page of the document
img = synthetize_page(result.pages[0].export())
plt.imshow(img); plt.show()

which yields:

Hope this helps :)
If I misunderstood you, please specify what you meant so that we can assist you 👌

Replies: 1 comment 1 reply

Comment options

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

Answer selected by PrasannaVpk
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