# Image Data Pipelines and Augmentation

> Loading, resizing and normalizing images efficiently, and using augmentation to multiply your effective dataset without collecting more labels. Free notes, key...

Canonical: https://www.internhack.in/roadmaps/tracks/machine-learning/image-data-pipelines
Last updated: 2026-11-28

Loading, resizing and normalizing images efficiently, and using augmentation to multiply your effective dataset without collecting more labels.

Intermediate · about 6 hours · difficulty 2/5

Learn first: [Convolutional Neural Networks](https://www.internhack.in/roadmaps/tracks/machine-learning/cnns)

In vision projects the data pipeline often matters more than the architecture. Slow loading starves the GPU, and inconsistent preprocessing between training and serving silently ruins accuracy.

### The pipeline

- **Decode and resize** to a fixed size; decide between cropping, padding or stretching.
- **Normalize** with the mean and standard deviation the pretrained model expects.
- **Folder layouts** such as `ImageFolder` (one directory per class) versus CSV manifests of paths and labels.
- **Parallel loading** with multiple workers and pinned memory; cache decoded images for small datasets.

### Augmentation

Augmentations are label-preserving transformations applied randomly at training time only.

- **Geometric**: random crops, flips, small rotations and scale changes.
- **Photometric**: brightness, contrast, colour jitter, blur.
- **Mixing methods**: Mixup and CutMix blend images and labels and act as strong regularizers.
- **Policy search**: RandAugment and TrivialAugment pick transformations automatically.

Always ask whether an augmentation keeps the label true. Horizontal flips are fine for cats but wrong for digit recognition or reading text. For detection and segmentation, boxes and masks must be transformed together with the image; libraries such as torchvision transforms v2 and Albumentations handle that.

### Checking your work

Display a grid of augmented batches before training. Most pipeline bugs (wrong channel order, labels shuffled separately, over-strong augmentation) are obvious when you look.

**Good enough to move on** when your GPU utilization stays high during training and you can justify every augmentation you apply.

## Key concepts

- **Resizing and normalization**
- **ImageFolder and manifests**
- **Geometric augmentation**
- **Photometric augmentation**
- **Mixup and CutMix**
- **RandAugment**
- **Albumentations**

## Mini project

Take 10 percent of a small image dataset and train the same CNN with no augmentation, basic flips and crops, and RandAugment plus Mixup. Report validation accuracy and plot a grid of augmented samples for each setting.

## Check yourself

Why should augmentation be applied to the training set only, and give one augmentation that would corrupt labels for a specific task.

## Free resources

- [torchvision transforms](https://pytorch.org/vision/stable/transforms.html) (PyTorch)
- [Albumentations documentation](https://albumentations.ai/docs/) (Albumentations)

Previous: [Convolutional Neural Networks](https://www.internhack.in/roadmaps/tracks/machine-learning/cnns) · Next: [Transfer Learning and Fine-Tuning](https://www.internhack.in/roadmaps/tracks/machine-learning/transfer-learning-vision)

## More in Computer Vision

- [Convolutional Neural Networks](https://www.internhack.in/roadmaps/tracks/machine-learning/cnns)
- [Image Data Pipelines and Augmentation](https://www.internhack.in/roadmaps/tracks/machine-learning/image-data-pipelines)
- [Transfer Learning and Fine-Tuning](https://www.internhack.in/roadmaps/tracks/machine-learning/transfer-learning-vision)
- [Object Detection](https://www.internhack.in/roadmaps/tracks/machine-learning/object-detection)
- [Image Segmentation](https://www.internhack.in/roadmaps/tracks/machine-learning/image-segmentation)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Machine Learning Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/machine-learning)
