Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add aspect ratio for ocr predictor #835

Merged
merged 4 commits into from
Mar 9, 2022
Merged

Conversation

charlesmindee
Copy link
Collaborator

This PR adds the option to preserve aspect ratio of the pages in the whole OCRPredictor pipeline, which leads to much better results on the detection task.
Any feedback is welcome!

@charlesmindee charlesmindee added type: enhancement Improvement module: models Related to doctr.models framework: pytorch Related to PyTorch backend framework: tensorflow Related to TensorFlow backend topic: text detection Related to the task of text detection labels Feb 25, 2022
@charlesmindee charlesmindee added this to the 0.5.1 milestone Feb 25, 2022
@charlesmindee charlesmindee self-assigned this Feb 25, 2022
Copy link
Contributor

@fg-mindee fg-mindee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!
I added a few comments, could you confirm whether this improves perf with the existing checkpoints? (it isn't specified in the PR details, so I prefer to make sure we use everything)

If that improves for existing checkpoints (trained with images that were stretched, that should strongly indicate that we should update our resizing strategy for detection training asap :))

doctr/models/predictor/base.py Show resolved Hide resolved
doctr/models/predictor/base.py Outdated Show resolved Hide resolved
@charlesmindee
Copy link
Collaborator Author

Yes @fg-mindee it doesn't hurt performances for now, and I will retrain all detection models preserving the aspect ratio to have a coherent pipeline, because it is way better not to deform writtings on documents for the model convergence!

fg-mindee
fg-mindee previously approved these changes Mar 7, 2022
Copy link
Contributor

@fg-mindee fg-mindee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@codecov
Copy link

codecov bot commented Mar 8, 2022

Codecov Report

Merging #835 (3c193cb) into main (0310d6c) will decrease coverage by 0.26%.
The diff coverage is 87.40%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #835      +/-   ##
==========================================
- Coverage   95.99%   95.73%   -0.27%     
==========================================
  Files         131      133       +2     
  Lines        5042     5131      +89     
==========================================
+ Hits         4840     4912      +72     
- Misses        202      219      +17     
Flag Coverage Δ
unittests 95.73% <87.40%> (-0.27%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
doctr/models/zoo.py 100.00% <ø> (ø)
doctr/models/predictor/base.py 81.81% <53.84%> (-18.19%) ⬇️
doctr/transforms/modules/pytorch.py 94.52% <84.61%> (-3.79%) ⬇️
doctr/transforms/modules/tensorflow.py 92.90% <90.90%> (-0.16%) ⬇️
doctr/transforms/functional/base.py 97.10% <97.61%> (+3.35%) ⬆️
doctr/io/pdf.py 100.00% <100.00%> (+1.66%) ⬆️
doctr/io/reader.py 100.00% <100.00%> (ø)
doctr/models/predictor/pytorch.py 97.29% <100.00%> (+0.07%) ⬆️
doctr/models/predictor/tensorflow.py 100.00% <100.00%> (ø)
doctr/transforms/functional/pytorch.py 100.00% <100.00%> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2581daa...3c193cb. Read the comment docs.

Copy link
Contributor

@fg-mindee fg-mindee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@charlesmindee charlesmindee merged commit a8e1908 into main Mar 9, 2022
@charlesmindee charlesmindee deleted the aspect_ratio branch March 9, 2022 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
framework: pytorch Related to PyTorch backend framework: tensorflow Related to TensorFlow backend module: models Related to doctr.models topic: text detection Related to the task of text detection type: enhancement Improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants