keplr-io / quiver

Interactive convnet features visualization for Keras
https://keplr-io.github.io/quiver/
MIT License
1.75k stars 223 forks source link

[bug] inconsistent preprocess_input #62

Open qinst64 opened 6 years ago

qinst64 commented 6 years ago

in the quiver code quiver_engine/imagenet_uitls.py:

x[:, :, :, 0] -= 103.939
x[:, :, :, 1] -= 116.779
x[:, :, :, 2] -= 123.68
# 'RGB'->'BGR'
x = x[:, :, :, ::-1]

in keras keras/applications/imagenet_utils.py:

# 'RGB'->'BGR'
x = x[..., ::-1]
 # Zero-center by mean pixel
x[..., 0] -= 103.939
x[..., 1] -= 116.779
x[..., 2] -= 123.68

minus+transpose and transpose+minus are apparently different, which leading prediction different results beween quiver vs. keras. However, I am not sure which of them is right.

jakebian commented 6 years ago

Yeah looks like Keras is right, good catch, fixing.

qinst64 commented 6 years ago

@jakebian Vgg16 is going great but when I use keras.applications.inception_v3 as the quiver input, the prediction is not as expected (quite bad).

Then I compared inception_v3.py and vgg16.py and find actually their preprocess_input are different. On the other hand, I may or may not use imagenet_util.preprocess_input for my own models.

I guess one solution is letting preprocess_input be a paramerer of quiver_engine.server.launch so one can apply custermized pre-processing.