August 2018
Intermediate to advanced
438 pages
12h 3m
English
Training such a complex network can be a tricky thing. For the purposes of this chapter, we have chosen a very small subset of images from ImageNet. To help our network learn and generalize, we use the ImageDataGenerator class from Keras to augment the dataset and produce variation in the input dataset. The following snippet showcases image augmentation and model training:
# Image transformerdatagen = ImageDataGenerator( shear_range=0.2, zoom_range=0.2, rotation_range=20, horizontal_flip=True)def colornet_img_generator(X, batch_size=BATCH_SIZE): for batch in datagen.flow(X, batch_size=batch_size): gs_rgb = gray2rgb(rgb2gray(batch)) batch_lab = rgb2lab(batch) batch_l = batch_lab[:,:,:,0] batch_l = batch_l.reshape(batch_l.shape+(1,)) ...
Read now
Unlock full access