mdietrichstein / tensorflow-open_nsfw

Tensorflow Implementation of Yahoo's Open NSFW Model
Other
430 stars 136 forks source link

Mean normalization vector correction #8

Closed colemakdvorak closed 5 years ago

colemakdvorak commented 6 years ago

Hi,

Just pointing out something I came across while I was reading the code. The image representation is converted from RGB to BGR, but the VGG_MEAN vector that contains the mean pixel value of dataset is in order of RGB.

For reference, the original implementation by Yahoo converts from RGB to BGR after mean normalization.

However, the image loader here scales the mean after reordering the channel. So the R and B values were being subtracted by means of B and R respectively. This is a fix that corrects this behavior.

bigthyme commented 6 years ago

+1, great find colemakdvorak!

mdietrichstein commented 5 years ago

Hey @colemakdvorak,

This issue is a bit tricky. The code you've linked to actually just configures the transformation.

If you look at the caffe transformer implementation you can see that the channels are swapped before subtracting the mean.