DEV Community

Cover image for Mosaic Image Augmentation for YOLO data
Arijit Gupta
Arijit Gupta

Posted on

Mosaic Image Augmentation for YOLO data

I couldn't really find anything online to easily convert my YOLO ready dataset into mosaic images (the nearest repository used a different format for the input annotations!) so I decided to write my own functional piece of code to make it convenient. While YOLOv4 onwards have an inbuilt functionality to load images in this format, some special cases like continual learning can require initial external augmentation before passing it to the model.

The code allows you to easily convert a set of 4 separate images and their corresponding annotations into a single mosaic and it also scales the bounding boxes accordingly. A sample mosaic from the Pascal VOC dataset would look like
Alt Text

You can find my code here and I hope people find it useful. Cheers!

Top comments (0)