Computer Vision News - September 2019

Data augmentation with Keras 17 This code loads an image and iterate through the augmentations object. The resulted new images are: Another useful and popular augmentation is a brightness shift . Changing the pixel intensity value is quite logic. It corresponds to two images of the same object that were taken in different illumination conditions. These two images, of course, should be classified for the same class. This is done in practice with the following change to the code: This class generates random augmentations on the fly with a specify parameters for each augmentation. For example, to generate a shifted image we simply use: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img import matplotlib.pyplot as plt import numpy as np img = load_img( 'shoes.jpg' ) data_generator = ImageDataGenerator(height_shift_range = 0.3 , width_shift_range = 0.3 ) X = img_to_array(img) i = 0 FinalImage = X X = X . reshape(( 1 ,) + X . shape) for batch in data_generator . flow(X): i += 1 FinalImage = concat_images(FinalImage, batch[ 0 ]) if i % 5 == 0 : break plt . axis( 'off' ) plt . imshow(array_to_img(FinalImage)) plt . show()

RkJQdWJsaXNoZXIy NTc3NzU=