October 2018
Intermediate to advanced
472 pages
10h 57m
English
The image_data_generator API transforms and augments the data in batches on the go, and is also super easy to use.
First, import the ImageDataGenerator:
from keras.preprocessing.image import ImageDataGenerator
Implement a random horizontal flip augmenter:
train_datagen = ImageDataGenerator(horizontal_flip=True)
Fit the augmenter on the train data:
# fit the augmentertrain_datagen.fit(X_train)
After the fit, we usually use the transform command. Here, instead of transform, we have the flow command. It accepts the images and its corresponding labels, and then generates batches of transformed data of the specified batch size.
Let's transform a bunch of images and look at the result:
# transform the datafor img, label ...
Read now
Unlock full access