Keras Best Data Data Generator Options for Data Augmentation

I am working on facial expression recognition with Keras, there is not a lot of data available in the dataset I am using, so I am going to use Keras image preprocessing to augment the data.

I want to know the best ImageDataGenerator parameters for generating normal faces that I can train my neural network with.

Here is the code I am using to augment the data:

def data_augmentation(subdir):

    datagen = ImageDataGenerator(
        featurewise_center=False,
        samplewise_center=False,
        featurewise_std_normalization=False,
        samplewise_std_normalization=False,
        zca_whitening=False,
        rotation_range=30,
        width_shift_range=0.2,
        height_shift_range=0.2,
        horizontal_flip=True,
        vertical_flip=False)

    print ("\nData augmentation...")
    print ("\nProcess...")

    for file in glob.glob(subdir+"*/*.jpg"):
        img = load_img(file)
        print ("\nProcessing..." + str(file))
        x = img_to_array(img)
        x = x.reshape((1,) + x.shape)

        i = 0
        for batch in datagen.flow(x, batch_size=1, save_to_dir='data_aug', save_prefix='Fig', save_format='jpg'):
            i += 1
            if i > 20:
                break

      

Here are all the ImageDataGenerator parameters

keras.preprocessing.image.ImageDataGenerator(featurewise_center=False,
                samplewise_center=False,
                featurewise_std_normalization=False,
                samplewise_std_normalization=False,
                zca_whitening=False,
                zca_epsilon=1e-6,
                rotation_range=0.,
                width_shift_range=0.,
                height_shift_range=0.,
                shear_range=0.,
                zoom_range=0.,
                channel_shift_range=0.,
                fill_mode='nearest',
                cval=0.,
                horizontal_flip=False,
                vertical_flip=False,
                rescale=None,
                preprocessing_function=None,
                data_format=K.image_data_format())

      

And here is an example of images created using my code:

enter image description here

enter image description here

enter image description here

enter image description here

As you can see, the images are distorted and not good enough to train my network.

I want to know what are the best ImageDataGenerator options for human faces or are there any better methods for augmenting data?

+5


source to share


2 answers


If you only deal with faces, check out this doc: http://www.openu.ac.il/home/hassner/projects/augmented_faces/ It can generate 30 images from one face image. Also you can use virtual makeup implements in python. They are easy to use and successful.



+1


source


You can also use random erase to make the web learn more about certain specific areas, rather than just focusing on certain parts of the face over the course of the training.



The random erasing paper can be found at https://arxiv.org/abs/1708.04896 and its implementation can be found at https://github.com/yu4u/cutout-random-erasing .

0


source







All Articles