Complete the code to import the library used for image data augmentation in Keras.
from tensorflow.keras.preprocessing.image import [1]
The ImageDataGenerator class in Keras is used to perform image data augmentation.
Complete the code to create an ImageDataGenerator that applies horizontal flips to images.
datagen = ImageDataGenerator([1]=True)
The horizontal_flip parameter enables random horizontal flipping of images during augmentation.
Fix the error in the code to correctly apply data augmentation to the training images.
train_generator = datagen.flow_from_directory(
'train_data',
target_size=(150, 150),
batch_size=32,
class_mode=[1]
)For multi-class classification, categorical is the correct class_mode to get one-hot encoded labels.
Fill both blanks to create a dictionary comprehension that maps image filenames to their augmented versions using the datagen.
augmented_images = {img: datagen.[1](img) for img in images if img.[2]('.jpg')}The flow method generates augmented images from input images, and endswith checks if the filename ends with '.jpg'.
Fill all three blanks to complete the code that applies rotation and zoom augmentation, then fits the generator to training images.
datagen = ImageDataGenerator(
rotation_range=[1],
zoom_range=[2]
)
datagen.[3](train_images)rotation_range=20 means images can rotate up to 20 degrees, zoom_range=0.15 means zooming up to 15%, and fit prepares the generator with the training images.