What is the correct way to call Keras flow_from_directory() method?
Please find a working solution here.

The generators look like:

# Data generators
train_datagen = ImageDataGenerator(
      rescale=1./255,
      rotation_range=40,
      width_shift_range=0.2,
      height_shift_range=0.2,
      shear_range=0.2,
      zoom_range=0.2,
      horizontal_flip=True,
      fill_mode='nearest')

# Note that the validation data should not be augmented!
test_datagen = ImageDataGenerator(rescale=1./255)

train_generator = train_datagen.flow_from_directory(
        # This is the target directory
        train_dir,
        # All images will be resized to 150x150
        target_size=(150, 150),
        batch_size=batch_size,
        # Since we use categorical_crossentropy loss, we need binary labels
        class_mode='categorical')

validation_generator = test_datagen.flow_from_directory(
        validation_dir,
        target_size=(150, 150),
        batch_size=batch_size,
        class_mode='categorical')


Make sure you have your images stored in the correct way. E.g.

...images/train/class1/
...images/train/class2/
...images/val/class1/
...images/val/class2/


The generator function does need this structure. So make sure there are subfolders for each class in the train/test directories.

You can also use the data generator function for prediction as described in this post.