Show progress bar for full-page OCR#512
Open
iRonin wants to merge 1 commit into
Open
Conversation
Contributor
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
The recognition / full-page OCR path (surya_ocr) ran silently, even though detection and layout already show tqdm bars. In full-page mode the batch is one item per page, so total=len(batch) is the page count and each completed item is a finished page. Wrap the executor with tqdm, gated by the existing settings.DISABLE_TQDM, matching the convention in surya/detection and surya/layout.
7089d24 to
b7d594c
Compare
Author
|
I have read the CLA Document and I hereby sign the CLA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #511.
Show a progress bar for full-page OCR
What
Add a
tqdmprogress bar tochat_completions_batch(the dispatch used byfull-page OCR /
surya_ocr), gated by the existingsettings.DISABLE_TQDM.Why
The recognition / full-page path was the only batched path with no progress
indication — detection, layout and the OCR-error model already use tqdm. On a
multi-page PDF
surya_ocrappeared to hang because nothing is printed until thewhole job finishes. In full-page mode the batch is one item per page, so
total=len(batch)is the page count and each completed item is a finished page.Change
(plus the two imports:
from surya.settings import settings,from tqdm import tqdm)Notes
DISABLE_TQDM, so users who set it keep silent output.executor.mappreserves the existing result ordering; tqdm advances as thein-order results are yielded. (Could use
as_completedfor finer-grainedupdates, but that would require re-sorting outputs by
metadataand is alarger change — happy to do that instead if preferred.)
chat_completions_batchis shared with the per-block fallback path, so thebar counts requests generically; in the dominant full-page path that is pages.
Tested
surya-ocr 0.20.0, llamacpp backend, Apple Silicon (MPS), 6-page scanned PDF,
SURYA_INFERENCE_PARALLEL=4:Output (
results.json/ markdown) unchanged.