-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
New YOLOv5 🚀 + Albumentations Official Integration!! #949
Comments
Great work @glenn-jocher ! |
Great work, thank you. But I'm encountering errors when I use "Normalize" function from Albumentations. Can you explain me the issue pls ? |
on google colab : after installing "pip install -U albumentations" Traceback (most recent call last): |
@testproducts20 this seems unrelated to YOLOv5. If I run this Colab I see the same error: !pip install -U albumentations
import cv2
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
[<ipython-input-1-b305364478bf>](https://localhost:8080/#) in <module>()
1 get_ipython().system('pip install -U albumentations')
2
----> 3 import cv2
3 frames
[/usr/local/lib/python3.7/dist-packages/cv2/__init__.py](https://localhost:8080/#) in <module>()
7
8 from .cv2 import *
----> 9 from .cv2 import _registerMatType
10 from . import mat_wrapper
11 from . import gapi
ImportError: cannot import name '_registerMatType' from 'cv2.cv2' (/usr/local/lib/python3.7/dist-packages/cv2/cv2.cpython-37m-x86_64-linux-gnu.so) @BloodAxe could you take a look at Colab compatibility for Albumentations? The opencv-headless install seems to be causing conflicts. To reproduce just run this in colab: !pip install -U albumentations
import cv2 |
@BloodAxe following up on this. Albumentation seems to have a serious Colab problem that users are encountering i.e. ultralytics/yolov5#7014, #1140. You can reproduce in Colab with: !pip install -U albumentations
import cv2 |
I checked what happened. Default colab has:
The albumentation requirements are given from the result of
After the pip -u albumentations
So, multiple versions may cause conflicts. I think there is no simple solution to this problem.
The package owner can not know which opencv package the user's environment has installed or none of them. Installing all of them with the same version seems to work, but it introduces unnecessary and redundant dependencies. |
This is more of a clarification than an issue but... Assuming you have albumentations installed, then Yolo will apply both the hyperparameters in the hyp.scratch-low.yaml (default) AND apply the albumentation pipeline defined in utils/augmentations.py. Since there are overlaps in the two capabilities, you could possibly end up canceling out an effect or, at the very least, end up with unexpected results. For example, if I have fliplr set in the hyperparameters but then use A.HorzontalFlip in the albumentation side, there is a chance that I could flip the same image twice (effectively canceling out the flip). Is this correct or am I over thinking this? It is definitely something to consider when using albumentations. |
@brownrc that's correct, albumentations are additive to existing augmentations. Though I think your conclusion is inconsistent with statistical additive noise, which always results in more noise and never cancels itself out statistically speaking. |
Thanks for the clarification, @glenn-jocher. |
@glenn-jocher how can I apply albumentations to both training and validation dataset? |
@glenn-jocher Hi, I have been unable to use albumentaion in a GCP compute engine environment. It keep s saying package not found, but the requirement is already satisfied. Also, why is it commented in the latest requirements.txt? |
Is there a way to add variables to the class Albumentations? |
I would like to add more randomness to the augmentation process. In this regard, Is there a way to apply different albumentation pipeline to each training image for instance? Currently all the parameters are fixed before training begins. |
how to add other albumentations in yolov8 execution like motion_blur,Imagecompression. |
I'm super excited to announce our new YOLOv5 🚀 + Albumentations integration!! Now you can train the world's best Vision AI models even better with custom Albumentations automatically applied 😃!
PR ultralytics/yolov5#3882 implements this integration, which will automatically apply Albumentations transforms during YOLOv5 training if
albumentations>=1.0.3
is installed in your environment.Get Started
To use albumentations simply
pip install -U albumentations
and then update the augmentation pipeline as you see fit in the newAlbumentations
class inyolov5/utils/augmentations.py
. Note these Albumentations operations run in addition to the YOLOv5 hyperparameter augmentations, i.e. defined in hyp.scratch.yaml.Here's an example that applies Blur, MedianBlur and ToGray albumentations in addition to the YOLOv5 hyperparameter augmentations normally applied to your training mosaics :)
Example Result
Example
![Open In Kaggle](https://camo.githubusercontent.com/1398db766d8ca60e6f296aac9ac429e344705c6c2c7e1ceb024230aac69fd6be/68747470733a2f2f6b6167676c652e636f6d2f7374617469632f696d616765732f6f70656e2d696e2d6b6167676c652e737667)
train_batch0.jpg
on COCO128 dataset with Blur, MedianBlur and ToGray. See the YOLOv5 Notebooks to reproduce:Update
To receive this YOLOv5 update:
git pull
from within youryolov5/
directory orgit clone https://github.com/ultralytics/yolov5
againmodel = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
sudo docker pull ultralytics/yolov5:latest
to update your imageThank you for your feedback and let us know if this update works for you, and of course feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀 + Albumentations!
The text was updated successfully, but these errors were encountered: