Mosaic Augmentation for Object Detection
See original GitHub issueMosaic augmentation for object detection is used in Yolo-V4 literature, FR. I’m not sure if it’s used for classification tasks there. I was wondering if it’s possible to do so for the image classification task. Here are two issues:
- References. Not sure if it’s ever used for classification only in any literature.
- Creation of class labels.
For creating class labels, here is one possible solution, described HERE; using Dirichlet distribution.
# for 2 images. Equivalent to λ and (1-λ)
>>> np.random.dirichlet((1, 1), 1)
array([[0.92870347, 0.07129653]])
>>> np.random.dirichlet((1, 1, 1), 1) # for 3 images.
array([[0.38712673, 0.46132787, 0.1515454 ]])
>>> np.random.dirichlet((1, 1, 1, 1), 1) # for 4 images.
array([[0.59482542, 0.0185333 , 0.33322484, 0.05341645]])
As mosaic takes 4 images.
update:
Mosaic augmentation for classification did use in literature. Please check: https://github.com/keras-team/keras-cv/issues/250#issuecomment-1130256698
Issue Analytics
- State:
- Created a year ago
- Comments:15 (10 by maintainers)
Top Results From Across the Web
Data Augmentation in YOLOv4 - Roboflow Blog
Mosaic [video] is the first new data augmentation technique introduced in YOLOv4. This allows for the model to learn how to identify objects...
Read more >YOLOX Explanation — Mosaic and Mixup For Data ... - Medium
Data augmentation is a way to help a model generalize. When augmenting data, the model must find new features in the data to...
Read more >Improved Mosaic: Algorithms for more Complex Images
The object detection model can identify the location and type of object by part of the object contour. 2.3. Improved Mosaic data augmentation...
Read more >Mosaic Data Augmentation - Deep Dive - YouTube
How to Use Amazon Rekognition Custom Labels and Roboflow to Build an Object Detection Model · Mix - Roboflow · How to Train...
Read more >Data Augmentation for Object Detection - Kaggle
Mosaic Augmentation ¶. In mosaic, instead of using 2 images we use 4 images. We stitch them together to make one big image...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We set the ground truth probability in proportion to the area occupied by each sample: https://github.com/AlexeyAB/darknet/blob/4ee3be7e68fb9c7eda5cc390e47e59f01e40dded/src/data.c#L1913-L1942 So if areas for: Car=10%, Table=20%, Cat=30%, Dog = 40%, then we set labels: Car=0.1, Table=0.2, Cat=0.3, Dog=0.4.
We have not tried using it in any other way.
Mosaic for Classifier reduces Top5-error from
6.0%
to5.5%
(-10 relative %) on Imagenet-1k, and it works better than CutMix/MixUp, Tables 2 and 3: https://arxiv.org/abs/2004.10934We used Mosaic data augmentation:
We didn’t use Mosaic for Classifier in (Scaled-YOLOv4, YOLOv5, YOLOR), just because they don’t need Classification or any pre-trained weights. We train these Detector from scratch to achieve the best accuracy/speed ratio.
It was originally introduced in the YOLOv4 paper: https://arxiv.org/abs/2004.10934
Some later work has used Mosaic:
Not sure but some suspicious feelings about the creation of
mosaic_x/y
,s1-s4
,center_x, center_y
. Can you check this and this implementation, it might give you some pointers.