본문 바로가기
목차
Python

[DL] CutMix and MixUp - Data Augmentation

by ds31x 2025. 6. 11.
728x90
반응형

1. CutMix (2019)란?

CutMix는 두 이미지를 결합할 때
한 이미지의 일부 영역(직사각형 patch)을 잘라
다른 이미지에 붙여넣는 방식의 Data Augmentation.

 

이때 레이블도 두 이미지의 비율에 맞게 혼합됨: soft labeling.

  • 이 방식은 이전에 제안된 MixUp이 이미지를 전체적으로 섞는 것과 달리,
  • 실제 이미지의 일부 영역 만을 교체하는 방식임.

관련 논문:

https://arxiv.org/abs/1905.04899

 

CutMix: Regularization Strategy to Train Strong Classifiers with Localizable Features

Regional dropout strategies have been proposed to enhance the performance of convolutional neural network classifiers. They have proved to be effective for guiding the model to attend on less discriminative parts of objects (e.g. leg as opposed to head of

arxiv.org


1-1. Principle (원리)

  • 이미지 A의 임의의 직사각형 영역을 잘라 이미지 B의 동일 위치에 덮어씌움.
  • label은 덮어씌운 영역의 비율($\lambda$)에 따라 A와 B의 label을 weighted sum.

1-2. Effect (효과)

  • 모델이 다양한 패턴과 컨텍스트를 학습할 수 있어 일반화 성능이 향상됨.
  • 두 클래스의 활성화 맵이 모두 잘 나타나, 여러 객체가 섞인 상황에도 강인한 모델로 학습시킴.

2. MixUp (2017)이란?

MixUp은
두 이미지를 픽셀 단위로 선형 보간(Interpolation)하여
새로운 이미지를 생성하는 Data Augmentation.

 

두 이미지를 $\alpha$-blending 하는 것이라고 보면 됨.

label도 동일한 비율로 weighted sum을 수행.

 

관련 논문:

https://arxiv.org/abs/1710.09412

 

mixup: Beyond Empirical Risk Minimization

Large deep neural networks are powerful, but exhibit undesirable behaviors such as memorization and sensitivity to adversarial examples. In this work, we propose mixup, a simple learning principle to alleviate these issues. In essence, mixup trains a neura

arxiv.org

 

$\alpha$-blending에 대해서는 다음을 참고:

https://dsaint31.me/mkdocs_site/DIP/cv2/ch01/dip_1_04/?h=blending

 

BME

Image Blending (or alpha Blending) 이것도 이미지 더하기 의 일종이지만, 이미지에 다른 가중치(\(\alpha\))를 부여하여 Blending 또는 transparency (투명감) 느낌을 부여함. 이는 아래 수식에 따라 더해짐: \[ g(i,j

dsaint31.me


2-1. Principle (원리)

  • 이미지 A와 B를 $\lambda: (1-\lambda)$ 비율로 섞어 새로운 이미지를 생성: $\lambda$는 [0.0, 1.0]의 random real number.
  • 레이블도 동일 비율로 weighted sum.

2-2. Effect (효과)

  • 모델의 일반화 성능의 향상.
  • corrupt label의 memorization을 방지
  • adversarial example에 sensitive해짐.

같이 보면 좋은 자료들

https://docs.pytorch.org/vision/main/auto_examples/transforms/plot_cutmix_mixup.html

 

How to use CutMix and MixUp — Torchvision main documentation

Shortcuts

docs.pytorch.org

 

https://gist.github.com/dsaint31x/1d42e36d70b3359d6e6a86803c3f6674

 

dl_cutmix_mixup-torchvision-transforms-v2.ipynb

dl_cutmix_mixup-torchvision-transforms-v2.ipynb. GitHub Gist: instantly share code, notes, and snippets.

gist.github.com


 

728x90