Data Augmentation Tips
1. Albumentations Library
ํน์ฅ์
๋ค์ํ Augmentation ๊ธฐ๋ฒ ๋ฐ ๋น ๋ฅธ ์๋๋ก augmentation pipeline์ ๊ตฌ์ฑํ ์ ์๋ ์คํ ์์ค ๋ผ์ด๋ธ๋ฌ๋ฆฌ
Kaggle Master๋ค์ด ์์ฑํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ก Kaggle, topcoder, CVPR, MICCAI์ ๋ง์ ์ปดํผ์ด์ ์์ ํ๋ฐํ ์ฌ์ฉ ์ค
๋ค์ํ Pixel ๋ ๋ฒจ ๋ณํ ๋ฐ Spatial ๋ ๋ฒจ ๋ณํ์ ์ง์ํ๋ฉฐ, ํ๋ฅ ์ ์ผ๋ก augmentation ์ฌ๋ถ๋ฅผ ์ ํํ ์ ์๊ณ OneOf block์ผ๋ก ์ ํ์ ์ผ๋ก augmentation ๋ฐฉ๋ฒ์ ์ ํ ๊ฐ๋ฅ
Benchmarking
Intel Xeon Platinum 8168 CPU์์ ImageNet ๊ฒ์ฆ์ ์ 2,000๊ฐ ์ด๋ฏธ์ง์ ๋ํ ๋ฒค์น๋งํน ์ํ
์๋ ํ๋ ๋จ์ผ ์ฝ์ด์์ ์ฒ๋ฆฌํ๋ ์ด๋น ์ด๋ฏธ์ง ์๋ก albumentation์ด ๋๋ถ๋ถ์ transform์์ 2๋ฐฐ ์ด์ ๋น ๋ฆ
Code Snippets
How to use
PyTorch์ torchvision๊ณผ ๋งค์ฐ ์ ์ฌ (5~10๋ถ์ด๋ฉด ์ตํ ์ ์์)
Documentation: https://albumentations.readthedocs.io/en/latest/
Colab์์ ์ฝ๊ฒ ํ ์คํธ ๊ฐ๋ฅ: https://colab.research.google.com/drive/1JuZ23u0C0gx93kV0oJ8Mq0B6CBYhPLXy#scrollTo=GwFN-In3iagp&forceEdit=true&offline=true&sandboxMode=true
Probability Calculation
: augmentation ์ ์ฉ ์ฌ๋ถ ํ๋จ (1์ผ ๊ฒฝ์ฐ์๋ ํญ์ augmentation ์ ์ฉ)
: 90๋ ํ์ ์ฌ๋ถ ๊ฒฐ์
:
OneOf
๋ธ๋ก ์ ์ฉ ์ฌ๋ถ ๊ฒฐ์ (๋ธ๋ก ๋ด ๋ชจ๋ ํ๋ฅ ์ 1๋ก ์ ๊ทํํ ๋ค์, ์ ๊ทํํ ํ๋ฅ ์ ๋ฐ๋ผ augmentation ์ ํ)์:
IAAAdditiveGaussianNoise
์ ํ๋ฅ ์ด 0.9์ด๊ณGaussNoise
์ ํ๋ฅ ์ด 0.6์ด๋ฉด ์ ๊ทํ ํ์๋ ๊ฐ๊ฐ 0.6๊ณผ 0.4๋ก ๋ณ๊ฒฝ๋จ
๊ฐ augmentation์ ์๋์ ๊ฐ์ ํ๋ฅ ์ด ์ ์ฉ๋จ
RandomRotate90
:IAAAdditiveGaussianNoise
:GaussianNoise
:
2. CutMix
Background
Cutout: ํ๋ จ ์ด๋ฏธ์ง์์ ์ผ๋ถ ์์ญ์ ๊ฒ์ ์ ํฝ์ ๋ฐ ๋๋ค ๋ ธ์ด์ฆ ํจ์น๋ก ์ค๋ฒ๋ ์ดํ์ฌ ์ ๊ฑฐ โ ์ผ๋ถ ๊ฒฝ์ฐ์ ์ ๋์ํ์ง๋ง ์์ object๋ ์ค์ํ ์์ญ์ ๋ํ ์ ๋ณด ์์ค์ด ๋ง์ด ๋ฐ์ํ๋ ๋ฌธ์
Mixup: ์ด๋ฏธ์ง์ ์ ๋ต ๋ ์ด๋ธ์ ์ ํ ๋ณด๊ฐ(linear interpolation)์ ํตํด ๋ ๊ฐ์ ์ํ์ ํผํฉ โ ์ง๋์น smoothing ํจ๊ณผ๋ก object detection์์ ๊ทธ๋ฆฌ ์ข์ง ์์
CutMix: ๋ ์ด๋ฏธ์ง์ ์ ๋ณด๋ฅผ ๋ชจ๋ ์ด๋ ค ๋ณด์๋ ์ทจ์ง
Algorithm
๋จผ์ , ํ๋ จ ์ด๋ฏธ์ง, ํด๋์ค, ๊ฐ ํด๋์ค์ ํด๋นํ๋ ํ๋ จ ์ํ์ ์๋์ ๊ฐ์ด ์ ์ํ๋ฉด,
๋ ๊ฐ์ ์ํ ์ด๋ฏธ์ง์ธ ๋ฅผ ์ฌ์ฉํ์ฌ ์๋ก์ด ์ํ ๋ฅผ ์์ฑํ ์ ์๋ค.
(: element-wise multiplication)
: 0์ด๋ 1๋ก ํํ๋๋ ์ฐจ์์ binary mask ์์ญ์ผ๋ก ์ด๋ ๋ถ๋ถ์ mixํ ๊ฒ์ธ์ง ๊ฒฐ์
์ ์์ญ์ ํ๋ผ๋ฉํฐ์ ์ํด ๊ฒฐ์ ๋๋ฉฐ, ๋ ์ด๋ฏธ์ง์์ ์๋ผ๋ผ ์์ญ์ ์๋ ค ์ฃผ๋ bounding box ์ขํ B๋ฅผ ๊ฐ์ ธ์์ ์ํ๋ง
๋ผ๋ ์ด๋ฏธ์ง๊ฐ ์์ ๋, ๋ด์ ํน์ bounding box ์์ญ์ ์ด๋ฏธ์ง๋ก๋ถํฐ ๊ฐ์ ธ์์ ๋ถ์
์ฆ, ์ bounding box ์์ญ B๊ฐ ์ ๊ฑฐ(crop)๋๊ณ ๊ทธ ์์ญ์ ์ bounding box B์์ ์๋ฆฐ ํจ์น๋ก ๋์ฒด๋จ(paste).
: mixing ratio๋ก ๋ฒ ํ ๋ถํฌ์ ์ํด ๊ฒฐ์
์ด๋ฅผ ์์์ผ๋ก ํํํ๋ฉด ์๋์ ๊ฐ๋ค.
๋ bounding box ์ค์ฌ ์ขํ์ด๋ฉฐ, uniform distribution์ ์ํด ๊ฒฐ์ ๋จ
๋ bounding box์ ๋๋น ๋ฐ ๋์ด๋ก, ์ด ์์์ ํตํด cropped area ratio ๋ ์๋์ ๊ฐ์ด ๊ณ์ฐํ ์ ์๋ค.
Code Snippets
Bounding box ์ขํ ์์ฑ
์ค์ ํธ์ถ ์์ (Kaggle Bangali.ai Handwritten recognition)
References
Paper
Albumentations: https://arxiv.org/pdf/1809.06839.pdf
Official
Albumentations: https://github.com/albumentations-team/albumentations
Video Clip (๊ฐ์ถ)
Albumentations: https://www.youtube.com/watch?v=n_f6d4bPFME
Last updated
Was this helpful?