How to let the Python and MATLAB wrappers work properly on classifying gray images?

233 views
Skip to first unread message

刘超

unread,
Dec 11, 2014, 7:56:41 AM12/11/14
to caffe...@googlegroups.com
Hi,

After checking the code and comments in these wrappers, I find that they may only run correctly when the pictures you want to classify have three channels without any modification, so I am curious if they can be changed to work well on gray pictures. I also find there is a lenet.prototext in example/mnist/, it treats pictures as its imput directly and that is different from the definition of the lenet_train_test.prototext which has to have the input data in lmdb format, so I guess there should be a way to do the classification on gray pictures as well ,but I just don't know how to do it. Here is doucument about how to use the python interface to do the classification:http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/examples/classification.ipynb

I would be so grateful if you can tell me how to do the trick. Thanks a lot.

Happy hacking~

Johnny ho

unread,
Dec 12, 2014, 3:16:59 PM12/12/14
to caffe...@googlegroups.com
You can work with grayscale image (with only 1 channel). Basically,what you do is to use /example/imagenet/create_imagenet.sh to create your lmdb / leveldm .mdb files from all your images. But in that script, you need to add --gray option, i.e., 

GLOG_logtostderr=1 $TOOLS/convert_imageset \
    --resize_height=$RESIZE_HEIGHT \
    --resize_width=$RESIZE_WIDTH \
    --shuffle \
    --gray \ 
    $VAL_DATA_ROOT \
    $DATA/val.txt \
    $EXAMPLE/ilsvrc12_val_lmdb

Then, your input can be grayscale image and it should properly.




GLOG_logtostderr=1 $TOOLS/convert_imageset \
    --resize_height=$RESIZE_HEIGHT \
    --resize_width=$RESIZE_WIDTH \
    --shuffle \
    --gray \
    $TRAIN_DATA_ROOT \
    $DATA/train_labeling_3d_axial_z_axis_length_5.txt \
    $EXAMPLE/tumor_train_lmdb_3d_axial_z_axis_length_5

刘超

unread,
Dec 15, 2014, 12:57:37 AM12/15/14
to caffe...@googlegroups.com
Thanks a lot!But actually this is not my problem, maybe my description confused you, sorry about that. 
Below is a link from another caffe user and it should describe my question properly.

在 2014年12月13日星期六UTC+8上午4时16分59秒,Johnny ho写道:
Reply all
Reply to author
Forward
0 new messages