Add mean file for classifying grayscale images

124 views
Skip to first unread message

Arush Kakkar

unread,
May 22, 2016, 8:03:52 AM5/22/16
to Caffe Users
Hello, 

I have trained alexnet on grayscale images, and the val accuracy is pretty good. 
While classifying, when I set the mean file of the training dataset that I created from "make_imagenet_mean.sh" on the custom dataset, transformer gives me the following error :

ValueError                                Traceback (most recent call last)
<ipython-input-17-3898d73eabce> in <module>()
      1 transformer = caffe.io.Transformer({'data': net.blobs['data'].data.shape})
----> 2 transformer.set_mean('data', mean)
      3 transformer.set_transpose('data', (2,0,1))
      4 transformer.set_raw_scale('data', 255)
      5 #net.blobs['data'].reshape(50, 1, 227, 227)

/usr/local/digits-2.0/caffe/python/caffe/io.pyc in set_mean(self, in_, mean)
    257 
    258     def set_input_scale(self, in_, scale):
--> 259         """
    260         Set the scale of preprocessed inputs s.t. the blob = blob * scale.
    261         N.B. input_scale is done AFTER mean subtraction and other preprocessing

ValueError: Mean shape incompatible with input shape.


Any solutions?

Arush Kakkar

unread,
May 22, 2016, 8:05:15 AM5/22/16
to Caffe Users
mean = np.array(caffe.io.blobproto_to_array(blob)).mean(1).mean(1)


This is the function I used to generate the meanfile.
Reply all
Reply to author
Forward
0 new messages