How can i specify grayscale image in caffe?

2,565 views
Skip to first unread message

蒋楠

unread,
Jul 2, 2015, 10:10:36 PM7/2/15
to caffe...@googlegroups.com
Hi,
I am using caffe with the grayscale image as input. I use the tool: convert_imageset to create the lmdb dataformat.

However, when I use my own CNN netowrk, with the data layer as following, the channel size of the first blob is 3, just like I am using the 3 channel image. The grayscale image is synthesized by myself in matlab, and when i load it in the matlab, it is also single channel. But why the caffe specify it as 3 channel? does it because I wrongly synthesized the grayscale image? or because i wrongly used the tool: convert_imageset ?

Has anybody met this problem before?  I appreciate all the reply you provide.

layer {
  name: "image"
  type: "Data"
  top: "dXataX"
  top: "ylabely"
  include {
    phase: TEST
  }
  transform_param {
    scale: 0.004                     #change here
  }
  data_param {
    source:  "../../data/syn_reshaped/train_lmdb"
    batch_size: 256
    backend: LMDB
  }
}
layer {
  name: "image"
  type: "Data"
  top: "dXataX"
  top: "ylabely"
  include {
    phase: TRAIN
  }
  transform_param {
    scale: 0.004                    #change here
  }
  data_param {
    source: "../../data/syn_reshaped/cv_lmdb"
    batch_size: 256
    backend: LMDB
  }
}

Venu Sharma

unread,
Jul 3, 2015, 4:11:04 AM7/3/15
to caffe...@googlegroups.com
Hello Nina,
   I think once you set the bool variable gray ON in convert_imageset and create LMDB your issue will be solved.

Regards

Tarun Sharma

unread,
Mar 20, 2016, 9:36:55 AM3/20/16
to Caffe Users
While calling convert_imageset, do convert_imageset --gray [training data location] [location to train.txt] [location where lmdb will be created]


On Friday, July 3, 2015 at 7:40:36 AM UTC+5:30, Nina wrote:

Oscar Beijbom

unread,
Mar 21, 2016, 12:15:38 AM3/21/16
to Caffe Users
you could also consider using a python data-layer for full control.


Oscar Beijbom

Chi Zhang

unread,
Oct 25, 2016, 4:43:30 PM10/25/16
to Caffe Users
Thanks Tarun. I found that with adding "--gray" the LMDB was created as single-channel but the values in each grayscale image are mormalized somehow. For example, in PASCAL VOC 2012, the segmentation label are PNG files with values 0, 1~20, 255, but I got some value like 90, 108, 113... Is there a way to keep original values as what it was in PNG images?

Thanks in advance.

Best,

Chi Zhang
Reply all
Reply to author
Forward
0 new messages