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

No normalization in prepocess_input function #116

Open
Schizophreni opened this issue Dec 27, 2019 · 1 comment
Open

No normalization in prepocess_input function #116

Schizophreni opened this issue Dec 27, 2019 · 1 comment

Comments

@Schizophreni
Copy link

In the file imagenet_utils.py, the prepocess_input function doesn't contain a normalization procedure, so if I am about to use pretrained VGG19, is it necessary to add this normalization procedure.
What's more, why should RGB be changed to BGR. In other websites, the mean value of an image is [123.68, 116.779, 103.939] for RGB, but in this file, it is reversed. which mean value is suitable for the VGG19 in the data format RGB? Do I need to change the image format from RGB to BGR if I want to transfer VGG19 to other tasks?
`def preprocess_input(x, dim_ordering='default'):
if dim_ordering == 'default':
dim_ordering = K.image_dim_ordering()
assert dim_ordering in {'tf', 'th'}

if dim_ordering == 'th':
    x[:, 0, :, :] -= 103.939
    x[:, 1, :, :] -= 116.779
    x[:, 2, :, :] -= 123.68
    # 'RGB'->'BGR'
    x = x[:, ::-1, :, :]
else:
    x[:, :, :, 0] -= 103.939
    x[:, :, :, 1] -= 116.779
    x[:, :, :, 2] -= 123.68
    # 'RGB'->'BGR'
    x = x[:, :, :, ::-1]
return x`
@liu09114
Copy link

Have the same problem. Solved?

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

2 participants