I want to use a pre-trained VGG16 in keras. My question is simple. Should I normalize the input image before predicting its label?

  • $\begingroup$ I tried this from scipy import ndimage from keras.preprocessing import image from keras.applications.vgg16 import preprocess_input im = scipy.misc.imread("cat_dog/validation/cats/cat.1362.jpg").astype(np.float32) im = scipy.misc.imresize(im, (224, 224)).astype(np.float32) im = np.expand_dims(im, axis=0) # im = preprocess_input(im) out = vgg16_model.predict(im) np.argmax(out) I tried to comment/uncomment the preprocess_input(...) and it apparently gave the same results and I think both sort of worked. The source for preprocess_input seemed to be at: github.com/tensorflow/tensorflow/blob $\endgroup$ Feb 24, 2018 at 3:47

1 Answer 1


According to Very Deep Convolutional Networks for Large-Scale Image Recognition, which is the paper that first presented VGG: "...The only pre-processing we do is subtracting the mean RGB value, computed on the training set, from each pixel."- (Karen Simonyan, Andrew Zisserman).

I am certain that Keras provides a preprocess function based on the above mentioned principle.

Checkout: tensorflow.keras.applications.vgg16.preprocess_input

If it is in the TF version, its certainly in the other version.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.