If you have ever worked on a Computer Vision project, you might know that using augmentations to diversify the dataset is the best practice. On this page, we will:
Let's get into it!
Mosaic data augmentation combines 4 training images into one in random proportions. The algorithms is the following:
Mosaic augmentation teaches the model to recognize objects in different localizations without relying too much on one specific context. This boosts the model’s performance by making the algorithm more robust to the surroundings of the objects.
Using Mosaic can be really helpful if objects in your dataset:
Images of people, animals, electronic components, satellite imagery, and many others might be good examples.
However, using Mosaic might not yield significant improvement if your dataset consists of:
# The formula for Alpha xc = np.random.randint(x_center - x_center * self.alpha, x_center + x_center * self.alpha) yc = np.random.randint(y_center - y_center * self.alpha, y_center + y_center * self.alpha)
As for now, the Albumentations library does not have a Mosaic transform function.
Still, if you want to use Mosaic, there are different implementations of this augmentation out on the Web. For example, please check out the GitHub repository featuring a ready-made Mosaic function you can straightaway use for your project.