Image Augmentation
Free data from the invariances you already know
Augmentation generates new training images by perturbing existing ones with the invariances your task actually has — rotations, flips, crops, color jitter. The right augmentation is often worth more than a bigger network.
What you will learn
- Choose transforms that match your task's invariances
- Understand the train/val discipline of augmentation
- Diagnose augmentation-induced label/quality errors
What is this?
Image augmentation applies label-preserving random transforms to training inputs each epoch — flips, rotations, resizing-crops, color/contrast jitter, noise, cutout — so the model sees 'new' images that keep the same label. It expands effective data, encodes prior knowledge (a cat flipped is still a cat) and serves as implicit regularization against overfitting.
Why do you need it?
- More effective samples = less overfitting, small datasets get a real lift.
- Encoding invariance you already know beats the network rediscovering it from too little data.
- Strong augmentation lets a small net match a bigger net on limited data.
- Modern pipelines (SimCLR, SSL) run on augmentation-heavy presets.
Mental model
Practicing a language with many fluent speakers' accents
Training under augmentation
Hearing English from a gardener, an engineer and a regional accent all labeled 'the same word' teaches persistence of meaning across noise — the model learns 'cat' despite any of the variations it will meet at test time.
How it works
- RandomHorizontalFlip: flips images horizontally — valid when handedness isn't task-relevant.
- RandomResizedCrop: take varied crops → scale invariance ('object is wherever it's big enough').
- ColorJitter: perturb brightness/contrast/hue → but only when color isn't the discriminator.
- Cutout/RandomErase: blank random patches → robustness to occlusion.
- Each stochastic transform re-rolls per image per epoch; the pipeline stays label-preserving.
One input image, many perturbed copies.
In production
- Most torchvision/Albumentations training recipes default to a flip+resize-crop+jitter stack.
- Defect/medical tasks use sparse augmentation classes to avoid creating anatomy-labels conflicts.
- SSL (SimCLR/BYOL) pipelines treat augmentation as a hyperparameter — heavier means better with care.
Best practices
- Choose transforms that match the task's true invariances; don't flip digits or vertical-only labels.
- Augment at train time only; evaluate on clean validation/test.
- Keep augmentation intensity on a par with what inference-time degradation you expect.
- Validate the composite: sample-augment 8 images and inspect them to catch broken means.
Common mistakes
- Vertical-flipping characters, medical anatomy or anything with gravity/reading direction.
- Augmenting validation data, which inflates your 'validation' estimate.
- Color jitter breaking the class signal (e.g. lemons vs limes, or tinted glass defects).
- So much augmentation the task becomes impossible — training loss stops descending.
Common issues
Augmented loss is higher across the boardIntensity too high or invariant-violating transforms
Turn down intensity or remove class-conflicting transforms; retest on val.
Validation better than train with heavy augAugmentation got applied at eval time
Set the pipeline to eval mode / skip transforms on validation.
Gray masks appear on some images in the gridNormalization mean/std vs augmented-scale mismatch
Normalize after transforms; keep the same stats for train and eval.
Debugging tips
- Render a grid of augmented images per epoch — visual inspection catches broken transforms fast.
- If accuracy on train stalls far from 1.0, cut augmentation intensity and re-check.
- Check the label space: don't flip class-specific channels when classes encode orientation.
- Compare model with/without augmentation at equal compute to assess its true contribution.
Interview checkpoint
Quick quiz
Which transform would you AVOID on handwritten digit recognition?
Augmentation should be applied to validation data to make estimates larger.