我在生成训练数据的平均图像时出现不正确的数据字段大小错误,即使在使用 create_imagenet.sh 生成后也是如此,为什么?

I am getting Incorrect data field size error while generating the mean image of training data, even after generating by using create_imagenet.sh,why?

我正在尝试从 caffe 中的训练数据生成平均图像。我的数据是 256x256 灰度图像。我通过使用 create_imagenet.sh 通过将 --shuffle 替换为 --gray 创建了 lmdb。

我编辑 create_imagenet.sh 如下:

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."

但是我在创建 mean image 时仍然遇到错误。

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

这里是错误:

    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)

有人对解决这个错误有什么建议吗?

非常感谢您的帮助。

确保您的图像是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
  }
}