Model Pipeline - Cutout and CutMix
This pipeline shows how Cutout and CutMix help improve image classification models by changing training images to make the model learn better. Cutout hides parts of images, and CutMix mixes parts of two images.
This pipeline shows how Cutout and CutMix help improve image classification models by changing training images to make the model learn better. Cutout hides parts of images, and CutMix mixes parts of two images.
Loss
1.2 |*
1.0 | *
0.8 | *
0.6 | *
0.4 | *
0.2 | *
0.0 +--------
1 5 10 15 20 Epochs| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 1.2 | 0.45 | Model starts learning, loss high, accuracy low |
| 5 | 0.8 | 0.65 | Loss decreases, accuracy improves with augmentation |
| 10 | 0.5 | 0.80 | Model learns robust features, accuracy rises |
| 15 | 0.35 | 0.88 | Loss low, accuracy high, good generalization |
| 20 | 0.30 | 0.90 | Training converged with strong performance |
import torch import torchvision.transforms as T cutout = T.RandomErasing(p=1.0, scale=(0.1, 0.1)) image = torch.randn(3, 224, 224) output = cutout(image) print(output.shape)
def cutmix(image1, image2, lam):
bbx1, bby1, bbx2, bby2 = rand_bbox(image1.size(), lam)
image1[:, bbx1:bbx2, bby1:bby2] = image2[:, bbx1:bbx2, bby1:bby2]
return image1
# image1 and image2 are tensors of shape (3, 224, 448)
# lam is a float between 0 and 1Pass the test and this pattern moves unknown