Offline vs On the Fly Augmentation Tradeoffs
Two Augmentation Strategies
Augmentation can happen before training (offline) or during training (on the fly). Each approach has distinct advantages for different scenarios.
Offline Augmentation
How it works: Generate augmented copies of each image before training starts. Store all variations on disk. Training reads pre-augmented images directly.
Advantages: No CPU overhead during training. Training runs at maximum speed. Useful when training is the bottleneck or when augmentations are computationally expensive.
Disadvantages: Fixed augmentations - the model sees the same variations every epoch. Storage multiplies by augmentation factor (10 augmentations = 10x storage). Changing augmentation strategy requires regenerating the entire dataset.
On the Fly Augmentation
How it works: Apply random augmentations to each image as it loads during training. Every epoch sees different variations of the same image.
Advantages: Infinite variation - the model never sees identical images twice. No additional storage. Easy to modify augmentation strategy mid-training.
Disadvantages: CPU overhead during training. Can become bottleneck if augmentations are complex or CPU is limited. Requires careful parallelization.
Choosing Your Strategy
Use offline when: Augmentations are expensive (neural style transfer, GANs). Storage is cheap. Training throughput is critical.
Use on the fly when: Augmentations are simple (flips, crops). Dataset is large and storage is limited. You want maximum variation.