Repository navigation
Add EasyOCR wrapper with rotation correction - #11
Merged
Merged
Conversation
khadijja1
approved these changes
Sep 7, 2026
Khubaib8281
approved these changes
Sep 7, 2026
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.
What does this PR do?
Adds ocr.py: wraps EasyOCR, tries all four right-angle rotations and keeps the best-scoring result, supports configurable languages per document type.
Which module(s) does it touch?
docling_pk/ocr.py. Depends on docling_pk/preprocessor.py.
How did you test it?
Tested against a real photo shot sideways: unusable output before rotation correction, correct output after. Also tested en+ur versus English-only on certificate images, since certificates are almost entirely English text and the combined model was introducing Arabic-script noise into English words.
Edge cases handled:
No detections returns empty text and 0.0 confidence rather than raising. Language list is configurable per call, defaults to en+ur.
Checklist:
Note: this PR was pushed earlier but the GitHub PR itself was never opened. This is the actual fix for the current CI failure (docling_pk.ocr missing from main). Recommend reviewing and merging this before PR #9 (Copilot's auto-fix).