The pipeline you'll actually write at work
For most real-world image projects, you have a directory of JPEG/PNG files organized by class. Two paths: the high-level keras.utils.image_dataset_from_directory for quick experiments, or a manual pipeline with tf.io.read_file when you need control.
The four antipatterns to avoid:
- Shuffling after batching — shuffles batches, not elements.
- Missing prefetch — GPU stalls between batches.
- Caching augmented data — same augmentation every epoch.
- Hardcoded num_parallel_calls — instead of
AUTOTUNE, which adapts.
When something feels slow, open TensorBoard's Input Pipeline Analyzer (Profile tab) and look for "Input Bound: 80%" — the canonical signal that data loading is the bottleneck, not model compute.