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 rotation option to both detection training scripts #765

Merged
merged 10 commits into from
Dec 29, 2021

Conversation

charlesmindee
Copy link
Collaborator

@charlesmindee charlesmindee commented Dec 28, 2021

This PR adds the ability to train with rotated samples, by simply passing --rotation as an argument of the CLI detection training scripts.
The default rotation transformation performed on your training set is +-90°, and no rotation on the validation set, but this can be easily modified.

Here is how it renders for a batch of training samples:
samples

Any feedback is welcome!

@charlesmindee charlesmindee added type: enhancement Improvement ext: references Related to references folder framework: pytorch Related to PyTorch backend framework: tensorflow Related to TensorFlow backend topic: object detection Related to the task of object detection labels Dec 28, 2021
@charlesmindee charlesmindee added this to the 0.5.0 milestone Dec 28, 2021
@charlesmindee charlesmindee self-assigned this Dec 28, 2021
@codecov
Copy link

codecov bot commented Dec 28, 2021

Codecov Report

Merging #765 (16c98a8) into main (c72da96) will decrease coverage by 0.04%.
The diff coverage is 92.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #765      +/-   ##
==========================================
- Coverage   96.00%   95.95%   -0.05%     
==========================================
  Files         129      129              
  Lines        4807     4824      +17     
==========================================
+ Hits         4615     4629      +14     
- Misses        192      195       +3     
Flag Coverage Δ
unittests 95.95% <92.00%> (-0.05%) ⬇️

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

Impacted Files Coverage Δ
doctr/utils/metrics.py 97.36% <ø> (ø)
doctr/transforms/functional/tensorflow.py 97.91% <83.33%> (-2.09%) ⬇️
doctr/utils/geometry.py 97.50% <87.50%> (-1.24%) ⬇️
doctr/datasets/detection.py 94.44% <100.00%> (+0.69%) ⬆️
...dels/detection/differentiable_binarization/base.py 93.52% <100.00%> (+0.03%) ⬆️
doctr/transforms/functional/pytorch.py 100.00% <100.00%> (ø)
doctr/transforms/modules/pytorch.py 97.67% <0.00%> (-2.33%) ⬇️

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 c72da96...16c98a8. 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 for the PR!
I raised a concern about the optimal order of transforms, cf my comments 👍

doctr/datasets/detection.py Outdated Show resolved Hide resolved
doctr/models/detection/differentiable_binarization/base.py Outdated Show resolved Hide resolved
doctr/transforms/functional/pytorch.py Outdated Show resolved Hide resolved
doctr/transforms/functional/tensorflow.py Show resolved Hide resolved
doctr/transforms/functional/tensorflow.py Outdated Show resolved Hide resolved
references/detection/train_pytorch.py Outdated Show resolved Hide resolved
references/detection/train_pytorch.py Outdated Show resolved Hide resolved
references/detection/train_pytorch.py Outdated Show resolved Hide resolved
references/detection/train_tensorflow.py Outdated Show resolved Hide resolved
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.

Added a few comments!

references/detection/train_pytorch.py Outdated Show resolved Hide resolved
references/detection/train_pytorch.py Outdated Show resolved Hide resolved
references/detection/train_tensorflow.py Outdated Show resolved Hide resolved
references/detection/train_tensorflow.py Outdated Show resolved Hide resolved
@charlesmindee
Copy link
Collaborator Author

rotation

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.

Almost there!

references/detection/train_pytorch.py Outdated Show resolved Hide resolved
references/detection/train_tensorflow.py Outdated Show resolved Hide resolved
references/detection/train_pytorch.py Outdated Show resolved Hide resolved
references/detection/train_tensorflow.py Outdated Show resolved Hide resolved
@fg-mindee
Copy link
Contributor

rotation

Isn't that gorgeous 😄
Great work @charlesmindee 👍

@charlesmindee
Copy link
Collaborator Author

I think for the train set it is OK, because if we don't rotate we don't want to use polygons and if we rotate we don't need polygons in the constructor because polygons are created in get_item when rotating boxes

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.

Looks good to me!

@fg-mindee fg-mindee added the ext: tests Related to tests folder label Dec 29, 2021
@charlesmindee charlesmindee merged commit 1770b2e into main Dec 29, 2021
@charlesmindee charlesmindee deleted the rot-training2 branch December 29, 2021 16:04
@fg-mindee fg-mindee added module: datasets Related to doctr.datasets module: models Related to doctr.models module: utils Related to doctr.utils topic: text detection Related to the task of text detection and removed topic: object detection Related to the task of object detection labels Dec 29, 2021
@fg-mindee fg-mindee added module: transforms Related to doctr.transforms type: new feature New feature and removed type: enhancement Improvement labels Dec 31, 2021
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 framework: pytorch Related to PyTorch backend framework: tensorflow Related to TensorFlow backend module: datasets Related to doctr.datasets module: models Related to doctr.models module: transforms Related to doctr.transforms module: utils Related to doctr.utils topic: text detection Related to the task of text detection type: new feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants