Keras: imagenet pretrained inception_v3 model mean value at inception_v3.py?

Created on 16 Feb 2017  路  4Comments  路  Source: keras-team/keras

def preprocess_input(x):
x /= 255.
x -= 0.5
x *= 2.
return x

 I am using keras inception_v3 imagenet pretrained model(inception_v3.py) to finetune on my own dataset.
 When I want to subtract the imagenet mean value [123.68, 116.779, 103.939] and reverse axis RGB to BGR as we often do, I find that the author provided a _preprocess_input()_ function at the end.I am confused about this.

  Are the authors using preprocess_input() function when they are training inception v3 model on Imagenet other than subtract mean?

  Should I use the provided function preprocess_input() or subtract mean value and reverse axis as usual?

  Thanks lot.
@fchollet @singlas @ozancaglayan

Most helpful comment

@kentsommer
You are right, I understand channel swap(because of the exists of 'th' and 'tf' order), but I don't exactly know why we need to do axis reverse(RGB to BGR), why don't we do axis reverse(RGB to BGR) when using Inception V3 or V4?

All 4 comments

@daoliker
The Inception-V3 model was trained using the preprocess_input as shown above (along with some cropping etc). You should use the included preprocess_input function, subtracting the mean value is not required).

@kentsommer Thanks. I got it. And does it mean that we subtract mean value and reverse axis RGB to BGR because the VGG16(VGG19 etc.) architecture do those operations on ImageNet while Inception-V3, Inception-V4 etc. don't when training on ImageNet?

@daoliker

I think you are confusing the channels first or last swap (3, height, width) -> (height, width, 3) with RGB to BGR swapping which is a different thing. However, your assumption is correct about why it is not performed on the Inception models.

@kentsommer
You are right, I understand channel swap(because of the exists of 'th' and 'tf' order), but I don't exactly know why we need to do axis reverse(RGB to BGR), why don't we do axis reverse(RGB to BGR) when using Inception V3 or V4?

Was this page helpful?
0 / 5 - 0 ratings