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

Possible mean subtraction error #62

Open
vvigilante opened this issue Jan 15, 2020 · 2 comments
Open

Possible mean subtraction error #62

vvigilante opened this issue Jan 15, 2020 · 2 comments

Comments

@vvigilante
Copy link

Here we see the preprocessing from the official source:
https://github.com/keras-team/keras-preprocessing/blob/master/keras_preprocessing/image/utils.py
The means are: (131.0912, 103.8827, 91.4953)

while in this repository we have

            x_temp[..., 0] -= 91.4953
            x_temp[..., 1] -= 103.8827
            x_temp[..., 2] -= 131.0912

It appears to me that both sources (this repository and the official source) use RGB channel order, so they should use the same order for the means.

The official order makes sense, because there is more red (131) than blue (91), and this appears right for face images.

Am I missing something or is this an error?
Thank you for your response!
Vincenzo

@james-oldfield
Copy link

james-oldfield commented Feb 28, 2020

@vvigilante right before this the RGB image seems to be converted first to BGR via

x_temp = x_temp[..., ::-1]

https://github.com/rcmalli/keras-vggface/blob/master/keras_vggface/utils.py#L44

So x_temp[..., 2] now correctly refers to the R channel, from which we subtract the larger mean. So this code indeed appears correct. Does this sound about right?

@vvigilante
Copy link
Author

Ok, thank you, then my error is about the channel order: the model is trained with BGR channel order.

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