IMG pre-processing python classifier for MNIST and CIFAR10 models in Caffe

42 views
Skip to first unread message

Gurunath Kadam

unread,
May 3, 2018, 12:04:02 AM5/3/18
to Caffe Users
I am writing a python classifier using the pre-trained models (MNIST and CIFAR10) available in Caffe.
I am following this tutorial:

For both classifiers, I will be feeding images (in png or pgm format most likely).

I am confused about the input preprocessing steps.
First, about the HWC->CHW, I know Caffe uses NCHW format, so is this transformation always needed?

Second, about the set_mean. I read that it improves classification accuracy in some cases, but is it true for all models?
How to know if this is needed?

Third, about the RGB->BGR swap. If I use a pre-trained model, how can I ensure if I need this transformation?
In the linked example, the caffemodel determines this. But how can I check this for the CIFAR model.
Also, I think this is not required for MNIST. Is that right?

The raw_scaling: I think I need to inverse this (scale images from 0 to 255 -> 0 to 1) because the models were by multiplying a scaling factor.

Thanks.

Przemek D

unread,
Aug 20, 2018, 6:24:47 AM8/20/18
to Caffe Users
The HWC->CHW conversion as well as RGB->BGR swap depend on the way you load your data. If you use OpenCV for example, you get HWC, BGR data and you need to transform. But if your image processing library gave you CHW, there's no need to transpose.
Mean subtraction is too broad a subject to discuss within a single answer, I suggest you read more about data preprocessing, starting for example here.
Reply all
Reply to author
Forward
0 new messages