-
-
Notifications
You must be signed in to change notification settings - Fork 16.4k
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
Copy-Paste augmentation #12599
base: master
Are you sure you want to change the base?
Copy-Paste augmentation #12599
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 Hello @Arno1235, thank you for submitting a YOLOv5 🚀 PR! To allow your work to be integrated as seamlessly as possible, we advise you to:
- ✅ Verify your PR is up-to-date with
ultralytics/yolov5
master
branch. If your PR is behind you can update your code by clicking the 'Update branch' button or by runninggit pull
andgit merge master
locally. - ✅ Verify all YOLOv5 Continuous Integration (CI) checks are passing.
- ✅ Reduce changes to the absolute minimum required for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee
@Arno1235 hello! Thank you for your interest in YOLOv5 and for bringing up the Copy-Paste augmentation. Your suggestion to enhance the augmentation by including additional transformations like flipping and scaling is indeed in line with the cited paper and could potentially improve the robustness of the model. We always welcome contributions from the community. If you're interested in implementing these improvements, feel free to fork the repo, make your changes, and submit a pull request. We'll be happy to review it. For guidelines on contributing, you can refer to our documentation. Keep in mind that any changes should be thoroughly tested to ensure they benefit the model's performance without introducing unexpected behavior. Thanks again for your input, and we look forward to any contributions you might make! 😊🚀 |
@Arno1235 this looks good, but one of the main issues may be speed. It looks like you have 2 cv2.warpaffine() calls in the innermost part of the for loops, which means that these will run very many times, and likely lead to very significant augmentation compute burden. |
Hi @glenn-jocher, thanks for the quick response! You're right. The code for shifting the array looks like this:
I tested the functionality and speed with the following program:
This gives output:
Do you think this is good enough? If the for loop concerns you, I could also do one random translation and check what translated objects are in the image and don't overlap with other objects and copy those (keeping the chance value p in mind). |
Hi @Arno1235, Great work on optimizing the augmentation process! It's impressive to see that your Your benchmarking results are promising, and it seems like your approach could be a good fit for the YOLOv5 project. If you've ensured that the functionality is consistent and that there are no edge cases or bugs, this could indeed be good enough to consider integrating. Regarding the for loop, your idea to perform a single random translation and then check for overlaps is a good one. It could further optimize the process by reducing the number of operations needed. If you're ready, you might want to proceed by submitting a pull request with your changes. Make sure to include your test cases and performance benchmarks so that we can review the full impact of your contribution. Thanks for your dedication to improving YOLOv5! 😊👍 |
Hi @glenn-jocher, I implemented the array shifting and made it only do a single translation in the code. |
Hi @Arno1235, Fantastic to hear that you've implemented the array shifting with a single translation! To include your test cases and performance benchmarks, you can follow these steps:
Remember to ensure that your tests are reproducible and that your benchmarks accurately reflect the performance improvements. This will help the reviewers during the pull request process. Looking forward to seeing your contribution! 😊🚀 |
I think this pull request is ready to be reviewed and merged if it is approved. Thanks |
Hi @Arno1235, Thank you for adding comments to your code and for preparing your pull request. Here's what you can do next:
Once you've submitted your PR, the maintainers will review your changes. They may request additional changes or clarifications, so be prepared to engage in the review process. It sounds like you've done a thorough job, and if everything is in order, there shouldn't be anything else you need to do for now. Just be responsive to any feedback you might receive during the review process. Thanks for your contribution, and we're looking forward to reviewing your work! 😊👍 |
Currently the Copy-Paste augmentation only flips the copied object and places it if it doesn't overlap too much.
This code places the copied object randomly on the image and places it if it doesn't overlap too much (like the cited paper explains https://arxiv.org/abs/2012.07177).
Possible improvements:
🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
📊 Key Changes
shift_array
function to handle image translation.copy_paste
augmentation method to include random translation with boundary checks and segment translation.🎯 Purpose & Impact
The changes introduce a more diverse Copy-Paste augmentation which can enhance model robustness by training it on images with objects pasted in variable positions. It makes the training process closer to real-world scenarios where objects can appear anywhere in the frame, thus helping the model generalize better. This could potentially improve object detection accuracy in unseen data.
🌟 Summary
Implemented enhanced Copy-Paste augmentation for better object detection model training. 🎨✂️📌