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

refactor: Avoids instantiating orientation predictor when unnecessary #809

Merged
merged 3 commits into from
Jan 18, 2022

Conversation

fg-mindee
Copy link
Contributor

@fg-mindee fg-mindee commented Jan 18, 2022

This PR introduces the following modifications:

  • simply saves a bit of memory by avoiding to instantiating the crop orientation predictor when it will never be used.
  • refactors predictor constructor (moving as many things as possible to base): that way, kwargs of DocumentBuilder can be directly passed to the high-level API ocr_predictor
  • updates unittests to check that the crop orientation predictor is only there when needed

Any feedback is welcome!

@fg-mindee fg-mindee added type: enhancement Improvement module: models Related to doctr.models labels Jan 18, 2022
@fg-mindee fg-mindee added this to the 0.5.1 milestone Jan 18, 2022
@fg-mindee fg-mindee self-assigned this Jan 18, 2022
@codecov
Copy link

codecov bot commented Jan 18, 2022

Codecov Report

Merging #809 (0450bbf) into main (45d4bfd) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #809      +/-   ##
==========================================
- Coverage   96.01%   96.00%   -0.01%     
==========================================
  Files         131      131              
  Lines        4942     4935       -7     
==========================================
- Hits         4745     4738       -7     
  Misses        197      197              
Flag Coverage Δ
unittests 96.00% <100.00%> (-0.01%) ⬇️

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 100.00% <100.00%> (ø)
doctr/models/predictor/pytorch.py 97.14% <100.00%> (-0.36%) ⬇️
doctr/models/predictor/tensorflow.py 100.00% <100.00%> (ø)

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 45d4bfd...0450bbf. Read the comment docs.

charlesmindee
charlesmindee previously approved these changes Jan 18, 2022
Copy link
Collaborator

@charlesmindee charlesmindee left a comment

Choose a reason for hiding this comment

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

thanks!

Copy link
Collaborator

@charlesmindee charlesmindee left a comment

Choose a reason for hiding this comment

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

Thanks!

@fg-mindee fg-mindee merged commit 4da0557 into main Jan 18, 2022
@fg-mindee fg-mindee deleted the crop-orientation branch January 18, 2022 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ext: tests Related to tests folder module: models Related to doctr.models type: enhancement Improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants