2

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.

4

1 回答 1

1

确保您的图像是,您必须在运行网络之前256X256将所有图像转换为相同的大小。

添加--gray到您的LMDB遗嘱中,将您的图像创建为单通道。

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
  }
}
于 2017-01-05T09:31:02.367 回答