2

I'm trying do do data augmentation with keras ImageDataGenerator. I'm pulling the images from a Dataframe containing the paths to the image in one column and the label in another one. For now, i'm only trying to flip the image horizontaly. But when I plot the images, the images look like the brightness was pushed to the max. I wonder what's going on here... Any thoughts?

datagen = ImageDataGenerator(horizontal_flip=True)


# Configure batch size and retrieve one batch of images
for X_batch, y_batch in datagen.flow_from_dataframe(dataframe=data,
    x_col="File name",
    y_col="Driving direction",
    directory = "Self-Driving-Car/Training Data/",
    target_size = (480, 640),
    class_mode = "other"):
    # Show 9 images
    for i in range(0, 9):
        plt.subplot(330 + 1 + i)
        plt.imshow(X_batch[i])
    plt.show()
    break

Here is one original image

Here are the augmented images

Robson
  • 813
  • 5
  • 21
  • 40
Adriendod
  • 79
  • 5

2 Answers2

4

Ok it was just a plotting problem, this solved it :

    plt.imshow(X_batch[i]/255)
Adriendod
  • 79
  • 5
1

More generally, be aware that if you do not have 0-255 ranged int images, ImageDataGenerator can rescale the data to 0-255 according to certain default values on certain of the augmentation options but not others. brightness_range being one example that rescales to 0-255.

J B
  • 348
  • 1
  • 6