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

Add rotation 90 degrees to augs #11792

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

Add rotation 90 degrees to augs #11792

wants to merge 20 commits into from

Conversation

ArgoHA
Copy link

@ArgoHA ArgoHA commented May 9, 2024

This is a PR to add one more type of augmentation for detection model. It's rotation to fixed 90 degrees (+ or -). User can choose a probability of this augmentation to be applied during the training.
I find this augmentation useful and decided to quickly implement it for my custom training pipeline. As this might be useful for others - I create this PR. Probability by default will be 0, so it won't be applied.

I have read the CLA Document and I sign the CLA

Note: I only tested bboxes implementation and I am not sure if rotating image and labels from scratch was the best solution, maybe I should've used Albumentation. Let me know how to make this PR better.

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Introducing 90-degree rotation augmentation to improve model robustness! πŸ”„

πŸ“Š Key Changes

  • Added a rotate90 option in the configuration (default.yaml) to enable random 90-degree rotations. πŸŽ›οΈ
  • Implemented a new class RandomRotation90 in augment.py for handling 90-degree image rotations. πŸ–ΌοΈ
  • This feature applies rotations not just to images, but also adjusts bounding boxes, segments, and keypoints accordingly. πŸ”§

🎯 Purpose & Impact

  • Enhances Data Augmentation: Provides an additional way to augment training data by randomly rotating images, making the model more robust to various orientations. πŸš€
  • Flexibility: The change introduces a probability parameter, letting users customize how often rotations are applied, adding flexibility to training configurations. 🎚️
  • Improved Accuracy: By allowing models to learn from more varied orientations, the potential for higher model accuracy and better generalization to real-world scenarios increases. 🎯

This update is perfect for users looking to push the boundaries of their model's accuracy by introducing more diverse training scenarios!

Copy link

codecov bot commented May 9, 2024

Codecov Report

Attention: Patch coverage is 25.71429% with 26 lines in your changes are missing coverage. Please review.

Project coverage is 70.48%. Comparing base (654c37f) to head (38ab7ca).

Files Patch % Lines
ultralytics/data/augment.py 25.71% 26 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11792      +/-   ##
==========================================
- Coverage   70.58%   70.48%   -0.11%     
==========================================
  Files         124      124              
  Lines       15648    15683      +35     
==========================================
+ Hits        11045    11054       +9     
- Misses       4603     4629      +26     
Flag Coverage Ξ”
Benchmarks 35.47% <17.14%> (-0.05%) ⬇️
GPU 37.21% <20.00%> (-0.05%) ⬇️
Tests 66.62% <25.71%> (-0.10%) ⬇️

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

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

@Burhan-Q Burhan-Q added the enhancement New feature or request label May 13, 2024
@ArgoHA
Copy link
Author

ArgoHA commented May 20, 2024

@Burhan-Q what should I do if test failed after merging current main branch? There were no conflicts, but test didn't run. Can I rerun it? And should I just wait for a PR review at this point?

@Burhan-Q
Copy link
Member

@ArgoHA I just re-ran the test for you. I believe that you can add a comment with only the text "recheck" (no quotes) to have the tests re-run.

@ArgoHA
Copy link
Author

ArgoHA commented May 22, 2024

@Burhan-Q sorry, I still don't understand what I need to do for this PR to be reviewed. Should I just wait?

@Burhan-Q
Copy link
Member

@ArgoHA I don't think I'll be able to provide a lot of input personally on the additions here as I'm not entirely familiar with the construction of the augmentation pipeline. I will share that at face value (I have not looked at your changes), the idea of including 90-degree rotation seems superfluous given the flip-lr, flip-up, and rotate hyperparameters, but I've been incorrect many times too πŸ˜†. If you are interested to have your changes reviewed or accepted, it would be important to test that your changes are compatible with all the tasks/models.

@ArgoHA
Copy link
Author

ArgoHA commented May 25, 2024

@Burhan-Q both flip-lr and flip-up won't change the width and hight of the image (if you don't transpose). You can't get 90 degree rotation with that. And speaking about rotate, it should work not as fixed angle, but max angle. So if I pass 90 to rotate, I will get randomly picked angle from -90 to + 90 which is again completely different thing. In some tasks you do need 90 degree fixed rotation, that's why I implemented it.
But I guess there is no point in waiting for the review, I'll close this PR. I will test other tasks if I have time and then create a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants