Cutmix Augmentation

Jino Rohit
2 min readDec 30, 2021

Yet another augmentation!

Last blog we talked about Mix-up and saw how we could improve our model performance with it. Incase you have missed it, here you go -
https://jinooo.medium.com/try-mixup-with-implementation-75e1f10d9e0b

You can think of this blog as an extension to the previous. Cutmix is yet another augmentation strategy that aims to improve on the shortcomings of the previous technique.
Let’s suppose you have two classes class A and class B, this is how cutmix works -
1. Draw a random bounding box on the images
2. Cut out the region of the bounding box of class A , and paste onto the class B image and vice versa.
3. Depending on the area of region cropped , we make the same mixture among the labels as well

Previous Methods

The previous methods like regional dropout which simply is cutting a random portion of the image and replacing it with blank pixels or with random noise results in lot of information loss since it is like zeroing out the region. Cutmix answers that by replacing the cut out part with a patch of another image.
Now we have two key features combined into one — regional dropout +
no loss of information . It’s all happy happy for now :)

Cutmix vs Mixup

Both of these techniques are very closely related but in case of mix-up you interpolates the images and labels and sort of make a whole new image itself and sometimes it can get very, I mean VERY WEIRD . In cutmix, it is simply a crop, cut and paste of random regions of different training samples.

Formula

new_image = M * image_i1 + (1 − M) * image_i2
new_labels = λ * label_j1 + (1 − λ) * label_j2
where —
* M is a binary mask that tells the region to be dropped and
copy pasted
* λ must be sampled between 0 and 1(beta distribution)

Whooohoooo time for hand’s on !

Hope this was yet another informative one , Happy New Year in advance !

--

--