For binary classification of cats and dogs images, my directory structure is train_dir/cats and train_dir/dogs.
train_datagen = ImageDataGenerator(rescale=1/255)
train_generator = train_datagen.flow_from_directory(
'/train_dir/', # This is the source directory for training images
target_size=(300, 300), # All images will be resized to 150x150
batch_size=128,
# Since we use binary_crossentropy loss, we need binary labels
class_mode='binary')
model.predict(images, batch_size=10)
How to know the probability return by model.predict() belongs to which class? is Cat=1 or dog=1? I read somewhere that for multiclass classification returned probabilities are in alphabetical order of class names. But I think that is not the case for binary classification.
You need to access class_indices
variable associated with each ImageDataGenerator
class. Just print train_generator.class_indices
to see which class is given which label.