Shirish Ranade
Shirish Ranade

Reputation: 98

Does prediction / fearure extraction based on keras pretrained models depend on pre_processing_input

Keras application has pretrained models with saved weights. These weights are independent of the nature of "preprocessing_input" on images it was trained with. Now when I submit my set of images for feature extraction depending upon my backend and mode, imagenet_utils will preprocessing_input and the iamge array processed will be either pixels scaled between -1 and 1 OR each color channel zero-centered with respect to the ImageNet dataset. Wouldn't prediction/feature extraction result in different results if I followed process outlined as say "Extract features with VGG16" in https://keras.io/applications/ ???

Upvotes: 1

Views: 71

Answers (1)

Dr. Snoopy
Dr. Snoopy

Reputation: 56377

No, weights are not independent from how inputs are preprocessed. If you use different preprocessing methods, the final weights will be different.

And as you say, if you use different preprocessing, then the features would be different. You should only use the preprocessing that was used for training the network.

This is why each network's python module contains a preprocess_input method that you can import to perform preprocessing. Each method might do different things depending on how the network is trained and what kind of preprocessing was used.

Upvotes: 1

Related Questions