Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'preprocess_input' defaults to 'caffe' rather than 'tf' #10279

Closed
ialhashim opened this issue May 24, 2018 · 3 comments
Closed

'preprocess_input' defaults to 'caffe' rather than 'tf' #10279

ialhashim opened this issue May 24, 2018 · 3 comments

Comments

@ialhashim
Copy link

ialhashim commented May 24, 2018

I was very confused when my 'cat' pictures where predicted as 'lampshade'. Shouldn't Tensorflow be the default?

def preprocess_input(x, data_format=None, mode='caffe'):

@fchouteau
Copy link

fchouteau commented May 24, 2018

Hi,

The preprocess_input function defaults to caffe because it is imported without modifications in keras.applications.vgg16 and keras.applications.resnet50 where those models were trained using caffe2 preprocessing. I suppose this was put in imagenet_utils to have sane defaults for those classic networks. (example: https://github.com/keras-team/keras/blob/master/keras/applications/vgg16.py#L29)

For more recent models such as Xception and MobileNet (where the training was under tf preprocessing), the preprocess_input function is actually redefined see: https://github.com/keras-team/keras/blob/master/keras/applications/xception.py#L267 for tf and https://github.com/keras-team/keras/blob/master/keras/applications/densenet.py#L325 for torch

@ialhashim
Copy link
Author

I see, I was testing Densenet so actually I should be using 'torch' or better yet import the corresponding preprocessing function and the model definition from 'densenet' (or other trained models).

@swghosh
Copy link

swghosh commented Jul 11, 2019

I had the same question. Thanks, @ialhashim @fchouteau for the clarification.

Does that mean the recommended way of using preprocessing_input from models like vgg16 and resnet50 be mode='caffe' (the default one) itself for getting correct predictions on a Tensorflow backend too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants