anishathalye / neural-style

Neural style in TensorFlow! 🎨
https://anishathalye.com/an-ai-that-can-mimic-any-artist/
GNU General Public License v3.0
5.54k stars 1.52k forks source link

Non-issue: Mean value from normalization? #101

Closed jppgks closed 6 years ago

jppgks commented 6 years ago

I'm trying to understand these two lines. https://github.com/anishathalye/neural-style/blob/b7461815c8fee73199709273c76daf69982db3ec/vgg.py#L26-L27

It seems like a mean value is being loaded from the data. Could you elaborate on what exactly is stored at data['normalization']? I'm trying to figure out what exactly it is the mean of.

anishathalye commented 6 years ago

The VGG network expects images to be preprocessed by subtracting the mean pixel values for the B, G, and R channels.

jppgks commented 6 years ago

@anishathalye Thanks for your quick response.

I understand that the network is trained on images where the mean pixel has been subtracted. I just don't see what is stored in data['normalization']. Are the mean pixel values stored there?

anishathalye commented 6 years ago

I think the man image is stored there, and the mean pixel can be calculated from that. Alternatively, we could have just hard-coded the mean pixel value.

jppgks commented 6 years ago

I see. How would you hard-code the mean pixel value? I mean, how would you compute it?

anishathalye commented 6 years ago
mean_pixel = [103.939, 116.779, 123.68]

https://gist.github.com/baraldilorenzo/07d7802847aaad0a35d3#gistcomment-1616734

jppgks commented 6 years ago

Ah, amazing 😊 I was seeing these constant values for the mean pixel, but I just didn't see where they were coming from. Thanks for freeing me from my confusion!