Custom Image Augmentation

Image Generation

Image Augmentation

Image augmentation is a technique that is used to artificially expand the data-set. This is helpful when we are given a data-set with very few data samples. In case of Deep Learning, this situation is bad as the model tends to over-fit when we train it on limited number of data samples.

Image augmentation parameters that are generally used to increase the data sample count are zoom, shear, rotation, preprocessing_function and so on. Usage of these parameters results in generation of images having these attributes during training of Deep Learning model. Image samples generated using image augmentation, in general results in increase of existing data sample set by nearly 3x to 4x times.

In Keras, we achieve Image augmentation with help of a function called as ImageDataGenerator. Basic outline of the function definition is as below:

Function to Initialize Data Augmentation Parameters

Custom Image Augmentation

Custom Image AugmentationWe may want to define our own preprocessing parameters for ImageDataGenerator in Keras in-order to make it a more powerful Image Generation API. We can achieve this by by making changes in the Keras file.

For the purpose of understanding, it always good to create copy of and do the changes in the duplicate copy. This is achieved on a Windows machine operating on Anaconda environment by following the below steps:

Steps to Create Custom Image Augmentation File —

Now add the custom parameters that you will like to see in ImageDataGenerator by following the below steps:

Experimental Results

Augmented Images Obtained Using - datagen_1
Augmented Images Obtained Using — datagen_2

Source Code

Show your support

Clapping shows how much you appreciated Shreenidhi Sudhakar’s story.