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

Closed
wants to merge 20 commits into from
Closed

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

Enhance your images with a twist! Introducing random 90-degree rotations for more dynamic data augmentation. πŸ”„

πŸ“Š Key Changes

  • Added a rotate90 configuration option in the default settings, allowing a chance from 0 to 1 to rotate images by 90 degrees during augmentation.
  • Introduced a new RandomRotation90 class dedicated to applying a 90-degree rotation to images, bounding boxes (bboxes), segments, and keypoints.

🎯 Purpose & Impact

  • Diverse Data for Training: By introducing more variability in the orientation of images, models can learn to recognize objects in a wider range of angles, potentially improving accuracy and robustness. πŸ“ˆ
  • Customizable Augmentation: With the rotate90 setting, developers and researchers can fine-tune how often images should be rotated, offering flexibility in data augmentation strategies. βš™οΈ
  • Enhanced Realism: Real-world scenarios often involve objects at various orientations; this update makes model training data more reflective of real-world conditions. 🌎

This change could significantly benefit users working on image recognition tasks, making models more versatile and reliable across different applications.

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

Burhan-Q commented May 24, 2024

@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-ud, 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.

@ArgoHA ArgoHA closed this May 28, 2024
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