A pipeline is an ordered path that turns data into model-ready batches and connects model construction with training. Keras supports several workflows, from simple fit() calls to highly flexible, manually controlled processes, so you can increase control without abandoning shared APIs. section 7.1 section 8.2.4
JPEG files to a trained image classifier
image_dataset_from_directory builds a Dataset that lists class directories, reads and decodes JPEG files, converts images to tensors, resizes them to 180×180, shuffles them, and batches them. The resulting train and validation datasets can pass directly to model.fit(), while callbacks save the best model and history records training and validation metrics. section 8.2.4
Build a practical input pipeline by composing these steps:
- Create a Dataset from arrays or files. section 8.2.4
- Inspect elements with iteration, then batch them with batch(). section 8.2.4
- Transform elements with map(), optionally parallelizing preprocessing and prefetching later batches. section 8.2.4
- Apply augmentation outside the model when CPU-side parallel processing is preferable, then train with fit(). section 8.2.5
Listing 8.9 Using image_dataset_from_directory to read images from directories
from keras.utils import image_dataset_from_directory batch_size = 64 image_size = (180, 180) train_dataset = image_dataset_from_directory( new_base_dir / "train", image_size=image_size, batch_size=batch_size ) validation_dataset = image_dataset_from_directory( new_base_dir / "validation", image_size=image_size, batch_size=batch_size ) test_dataset = image_dataset_from_directory( new_base_dir / "test", image_size=image_size, batch_size=batch_size )
Use the directory-loading listing as a compact starting point for a train/validation/test image pipeline. section 8.2.4















































