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

Image normalization in retrain.py script with Mobilenet_v1_1.0_224 module #52

Closed
haoxi911 opened this issue May 18, 2018 · 2 comments
Closed

Comments

@haoxi911
Copy link

Can anyone please help me understand how the retrain.py script normalize the image input data in TensorFlow Hub?

In the previous version of retrain.py (before TensorFlow Hub), it'll subtract pixels by 127.5 and then divide by 127.5, for a pixel in range [0, 255], this normalized its input to range [-1, 1], which seems to be correct.

In current retrain.py script, image was resized to 224x224 but the pixels were kept in range [0, 255], I know we have a module_apply_default/hub_input node in the graph to preprocess the input, however it seems that only multiples values by 2 and subtracts by 1.

I bet that we also divided the inputs by 255.0 somewhere, if so, the input will become [0, 1] before feeding into the module, and will be multiple by 2 and subtract by 1, and result a range [-1, 1].

My question is I didn't see where we divide the inputs by 255.0, so can anyone please clarify this?

Thanks!

@svsgoogle
Copy link
Contributor

The division happens in the lines with "tf.image.convert_image_dtype(...)".

@haoxi911
Copy link
Author

@svsgoogle thank you! Sorry I am not quite familiar with the APIs :)

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