Urgently need help with Imagedata and transformations

20 views
Skip to first unread message

Sreejith Balakrishnan

unread,
Oct 31, 2016, 6:41:51 AM10/31/16
to Caffe Users
Hi Everyone,

I am in the last week of a project I am doing with Caffe and I am getting terrible results (prototxt attached). The accuracy gets stuck at around 0.07 regardless of the input image I give to the network. After a lot of troubleshooting, I have the following observation:

1) Weights of layer "conv1" is copied from PlacesNet and is therefore pretrained. But when I visualize the blob "conv1" (which I believe is the result of the convolution) after a forward pass, it does not change for whatever input I give (see images for conv1 out for two data). So somehow the convolution doesn't seem to work.

2) Upon further investigation, I realized that the mean value file given to me is in the BGR format. Where as the raw images ('data' layer) are jpg images and therefore RGB. Can someone please explain to me how caffe handles RGB and BGR. I read in many places that caffe uses BGR. Lot of examples that use transform to convert RGB to BGR are doing so at the testing state of an already trained network. So do I have to preprocess all my training data to BGR before I can give it to ImageData layer? Or should I convert my mean values from BGR to RGB before specifying it in the ImageData?

3) Will creating lmdb out of the images as shown in the Imagenet example offer any benefit?

4) I noticed something strange with the 'data' blob. If the original image (when opening in matlab) is of the form:
 red channel: img[:,:,1] = [a1,a2,a3;a4,a5,a6;a7,a8,a9], 
 green channel: img[:,:,2] = [b1,b2,b3;b4,b5,b6;b7,b8,b9],
 blue channel: img[:,:,3] =  [c1,c2,c3;c4,c5,c6;c7,c8,b9]
When I print out the "data" blob per channel, I am getting this:
channel 1: [[a1,b1,c1],[a2,b2,c2],[a3,b3,c3]] and so on

But when I plot "data" blob using opencv, it displays it correctly. What is going on here? Is this expected?

Any help will be greatly appreciated since I am really short of time. Thank you. I am using pycaffe by the way.

Thanks, 
Sreejith
train_team_shifted.prototxt
conv1_output_data1.png
conv1_output_data2.png
Reply all
Reply to author
Forward
0 new messages