Home > Software engineering >  Image Data Generator not producing image after giving preprocessing function argument as None?
Image Data Generator not producing image after giving preprocessing function argument as None?

Time:12-13

I was understanding image classification using Keras. There was a function called image data generator which was used to prepare an image for processing.

train_batches = ImageDataGenerator(preprocessing_function=tf.keras.applications.vgg16.preprocess_input) \
    .flow_from_directory(directory=train_path, target_size=(224,224), classes=['cat', 'dog'], batch_size=10)

imgs, labels = next(train_batches)

Then I called this function to check the image

plt.imshow(imgs[0])

It gave me a decolorized and resized version of the original image.

However, when i tried this: -

train_batches = ImageDataGenerator(preprocessing_function=None) \
    .flow_from_directory(directory=train_path, target_size=(224,224), classes=['cat', 'dog'], batch_size=10)

or

train_batches = ImageDataGenerator() \
    .flow_from_directory(directory=train_path, target_size=(224,224), classes=['cat', 'dog'], batch_size=10)

then it gave blank.

For certain images, I can see faint outlines but not the image itself.

Ideally, it should have given the original image (resized) right? Because there is no preprocessing involved?

Can anyone tell me how to get the original image from a Directory Iterator?

CodePudding user response:

There is preprocessing involved. The enter image description here

  • Related