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: Introduces img + target transforms in Datasets #750

Merged
merged 12 commits into from
Dec 24, 2021
Merged

Conversation

fg-mindee
Copy link
Contributor

Following up on #352, this PR introduces the following modifications:

  • renames "sample_transforms" into "img_transforms" to be more explicit (hesitated with "input_transforms" but we only cover Vision, so I don't think it's necessary)
  • adds "sample_transforms" which are performed after "img_transforms" on both the image and the target
  • reflected changes in datasets, unittests and training scripts
  • added SampleCompose (to compose sample_transforms) and ImgTransformation (to wrap an img_transform as a sample_transform) utils
  • added dedicated unittests

With this PR, the way to pass thransforms becomes the following:

  • if you only have transformations that don't modify the target, pass them as img_transforms
  • if you have both, there are two options:
    • passing the image transformations that have to be performed before the first one to modify the target & pass the rest as sample_transforms:
    • passing all transformations as sample_transforms and when there is one that is only implemented for image, wrap it with ImageTransform

Any feedback is welcome!

@fg-mindee fg-mindee added type: enhancement Improvement ext: tests Related to tests folder type: breaking change Introducing a breaking change module: datasets Related to doctr.datasets ext: references Related to references folder module: transforms Related to doctr.transforms labels Dec 24, 2021
@fg-mindee fg-mindee added this to the 0.5.0 milestone Dec 24, 2021
@fg-mindee fg-mindee self-assigned this Dec 24, 2021
@codecov
Copy link

codecov bot commented Dec 24, 2021

Codecov Report

Merging #750 (b02b39f) into main (efe41da) will increase coverage by 0.10%.
The diff coverage is 90.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #750      +/-   ##
==========================================
+ Coverage   96.09%   96.20%   +0.10%     
==========================================
  Files         129      129              
  Lines        4794     4799       +5     
==========================================
+ Hits         4607     4617      +10     
+ Misses        187      182       -5     
Flag Coverage Δ
unittests 96.20% <90.66%> (+0.10%) ⬆️

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

Impacted Files Coverage Δ
doctr/models/predictor/base.py 100.00% <ø> (ø)
...dels/detection/differentiable_binarization/base.py 90.76% <73.91%> (+0.38%) ⬆️
doctr/datasets/detection.py 94.28% <90.90%> (-2.78%) ⬇️
doctr/datasets/classification/base.py 93.75% <100.00%> (+0.20%) ⬆️
doctr/datasets/cord.py 97.36% <100.00%> (-0.07%) ⬇️
doctr/datasets/datasets/base.py 95.74% <100.00%> (+0.29%) ⬆️
doctr/datasets/doc_artefacts.py 93.93% <100.00%> (-0.18%) ⬇️
doctr/datasets/funsd.py 96.77% <100.00%> (-0.11%) ⬇️
doctr/datasets/ic03.py 97.14% <100.00%> (-0.08%) ⬇️
doctr/datasets/ic13.py 97.22% <100.00%> (-0.08%) ⬇️
... and 10 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 efe41da...b02b39f. Read the comment docs.

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 for the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ext: references Related to references folder ext: tests Related to tests folder module: datasets Related to doctr.datasets module: transforms Related to doctr.transforms type: breaking change Introducing a breaking change type: new feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants