I am trying to generate the mean image from training data in caffe. My data is 256x256 grayscale images. I created lmdb by using create_imagenet.sh by replecing --shuffle with --gray.

I edited create_imagenet.sh as follows:

GLOG_logtostderr=1 $TOOLS/convert_imageset \
    --resize_height=$RESIZE_HEIGHT \
    --resize_width=$RESIZE_WIDTH \
    --gray \
    $TRAIN_DATA_ROOT \
    $DATA/train.txt \
    $EXAMPLE/train_lmdb

echo "Creating val lmdb..."

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

echo "Done."

But I am still getting error while creating mean image.

 /home/user1/caffe-master/build/tools/compute_image_mean -backend=lmdb /home/user1/input/train_lmdb /home/user1/input/train_mean.binaryproto

Here is the error:

    F0105 14:50:52.470038  2191 compute_image_mean.cpp:77] Check failed: size_in_datum == data_size (64000 vs. 65536) Incorrect data field size 64000
*** Check failure stack trace: ***
    @     0x7faa4978d5cd  google::LogMessage::Fail()
    @     0x7faa4978f433  google::LogMessage::SendToLog()
    @     0x7faa4978d15b  google::LogMessage::Flush()
    @     0x7faa4978fe1e  google::LogMessageFatal::~LogMessageFatal()
    @           0x402be1  main
    @     0x7faa486da830  __libc_start_main
    @           0x403249  _start
    @              (nil)  (unknown)
Aborted (core dumped)

Does anyone have any suggestion to tackle this error?

Your help is really appreciated.

1

There are 1 answers

7
Z.Kal On BEST ANSWER

Make sure your images are 256X256, you must convert all the images into a same size before runing the net.

adding --gray to your LMDB will create your images as single-channel.

layer {
  name: "data"
  type: "Data"
  [...]
  transform_param {
    scale: 0.1
    mean_file_size: mean.binaryproto
    # for images in particular horizontal mirroring and random cropping
    # can be done as simple data augmentations.
    mirror: 1  # 1 = on, 0 = off
    # crop a `crop_size` x `crop_size` patch:
    # - at random during training
    # - from the center during testing
    crop_size: 256 # cropping your images
  }
}