Keras - proper use of preprocess_input within ImageDataGenerator

Viewed 1480

I am trying to fine-tune an Inception-V3 model in keras. As such, I want to preprocess the images to fit the model using the build-in preprocessing function and flow_from_dataframe.

However, I am not sure how to properly use keras.applications.inception_v3.preprocess_input within the ImageDataGenerator

Moreover, I found two ways of doing this:

1)

datagen=ImageDataGenerator(preprocessing_function=keras.applications.inception_v3.preprocess_input)

2)

def preprocess_input_new(x):
   img = keras.applications.inception_v3.preprocess_input(img_to_array(x))
   return image.array_to_img(img)

datagen=ImageDataGenerator(preprocessing_function=preprocess_input_new)

both ways seem to yield sensible but different results, hence I wonder which one is preferred / correct?

0 Answers
Related