The reason for slowness is ImageDataGenerator (see this). Here’s my recommendation:
- Use
image_dataset_from_directoryto iterate on model architecture. - Swap
image_dataset_from_directorywithImageDataGeneratorafter finalizing the model architecture and pay the price once to please the grader.