Image normalization in retrain.py script with Mobilenet_v1_1.0_224 module
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!
The division happens in the lines with "tf.image.convert_image_dtype(...)".
@svsgoogle thank you! Sorry I am not quite familiar with the APIs :)