-
-
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
Add random interpolation method augmentation #6826
Conversation
@developer0hye thanks for the idea! The implementation is not quite right though, as the random interp method selection should only apply during training and not during detect/val. The training distinction can be made here in load_images() L643: Lines 627 to 647 in 8a66eba
|
@glenn-jocher Should I edit load_image function to apply this augmentation? |
@developer0hye I'll try to update this accordingly |
@developer0hye ok I've applied some updates. I think this will slow down training somewhat as INTER_CUBIC and INTER_LANCZOS4 are much heavier ops than the current INTER_LINEAR. I'll train a COCO model and we can see the results in a few days. |
@developer0hye interpolation profiling results: Colab++ V100 High-memimport cv2
import numpy as np
from utils.general import Profile
im = cv2.imread('data/images/bus.jpg')
method = (cv2.INTER_NEAREST, cv2.INTER_LINEAR, cv2.INTER_CUBIC, cv2.INTER_AREA, cv2.INTER_LANCZOS4)
print('Resize 640 to 320')
for m in method:
with Profile():
for _ in range(100):
cv2.resize(im, (320, 320), interpolation=m)
print('Resize 640 to 1280')
for m in method:
with Profile():
for _ in range(100):
cv2.resize(im, (1280, 1280), interpolation=m) |
@glenn-jocher Thanks for sharing your results! |
@developer0hye I wasn't able to generate any mAP improvement using this method unfortunately. I trained COCO from scratch before and after here:
|
@developer0hye it did slighly redue obj loss though. Perhaps this simply reduced mAP because the model had not overfitted sufficiently, and it's possible the method would benefit larger models more. |
Is there any progress on this item? |
@developer0hye based on the above test results (PR produces worse mAP on COCO) we don't want to implement this as a default choice. Perhaps this could be left as an option that is disabled by default. |
Yes, I agree with you. Have you ever tested with a larger model? |
@developer0hye yes it's possible this belongs with the other aggressive augmentation techniques that only benefit larger models, like higher 0.9 scale jitter. It's also possible that the location information gets lost when downsampling on some of these techniques, which might cause it to be more suitable to classification augmentation instead of detection augmentation. But I'll try to run with a larger model when I get some free GPUs. |
@developer0hye training now with YOLOv5x COCO 640 at https://wandb.ai/glenn-jocher/v7_retrain |
Thanks a lot! What is yolov5-7bx? |
@developer0hye yolov5x-7bx is just a v7.0 release candidate that we are testing. It's not important, as there are many experiments that we run like this one. The important thing is to compare yolov5x-7bx to yolov5x-7bx-randinterp for an apples to apples comparison of the effect of this PR. |
@glenn-jocher |
What do you think of the results? I think that we should measure mAPs with various resize setting to compare the performance of |
@developer0hye PR is merged. I retained the current interpolation behavior as was not able to produce mAP gains using the proposed method (may be more suitable for classification than detection), but left the random interp idea commented for possible future use. Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐ |
@glenn-jocher |
* add random_interpolation option to make model robust to interpolation methods * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix precommit error * Update augmentations.py * Update augmentations.py * Update augmentations.py * Update datasets.py * Update datasets.py Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher <[email protected]>
* add random_interpolation option to make model robust to interpolation methods * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix precommit error * Update augmentations.py * Update augmentations.py * Update augmentations.py * Update datasets.py * Update datasets.py Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher <[email protected]>
@developer0hye you're welcome! If you have any more questions or suggestions, feel free to reach out. Your input is greatly appreciated. |
I couldn't test this augmentation on COCO dataset because I don't have computing power to do this test.
I referenced one of the timm's augmentation methods and ross wightman's tweet.
🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Enhanced image resizing options during dataset loading in YOLOv5.
📊 Key Changes
🎯 Purpose & Impact