如何为caffe输入准备灰度图像数据

时间:2016-09-22 13:58:46

标签: deep-learning caffe

我已经阅读了很多参考文献,为caffe输入准备图像数据,但还没能解决我的问题!!

我已将.jpg个图像文件放在两个单独的文件夹中:

folder  train: containing 100,000 image files of size 227*227
folder val: containing 9,000 image files of size 227*227

我把它们放在/home/user/DL

的文件夹中

然后我制作了两个文本文件,列出trainval个文件夹中图片的名称:

.
.
p127.jpg 2
p943.jpg 2
p8765.jpg 1
.
.

我把这两个文件放在/home/user/caffe-master/data/DL

DL_create.sh位于/home/user/caffe-master/examples/DL,如下:

set -e

EXAMPLE=examples/DL
DATA=data/DL
TOOLS=build/tools

TRAIN_DATA_ROOT=/home/user/DL/train/
VAL_DATA_ROOT=/home/user/DL/val/


RESIZE=true
if $RESIZE; then
  RESIZE_HEIGHT=227
  RESIZE_WIDTH=227
else
  RESIZE_HEIGHT=0
  RESIZE_WIDTH=0
fi

if [ ! -d "$TRAIN_DATA_ROOT" ]; then
  echo "Error: TRAIN_DATA_ROOT is not a path to a directory:  $TRAIN_DATA_ROOT"
  echo "Set the TRAIN_DATA_ROOT variable in create_DL.sh to  the path" \
       "where the DL training data is stored."
  exit 1
fi

if [ ! -d "$VAL_DATA_ROOT" ]; then
  echo "Error: VAL_DATA_ROOT is not a path to a directory: $VAL_DATA_ROOT"
  echo "Set the VAL_DATA_ROOT variable in create_DL.sh to the path" \
       "where the DL validation data is stored."
  exit 1
fi

echo "Creating train lmdb..."

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

echo "Creating val lmdb..."

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

echo "Done."

然后,当我运行DL_create.sh脚本将我的图片数据更改为lmdb时,它无法找到我的图片并发出如下消息:

.
.
.
E0922 14:35:24.152361 31301 io.cpp:80] Could not open or find file /home/user/caffe-master/data/DL/train/p84167.jpg
E0922 14:35:24.160773 31301 io.cpp:80] Could not open or find file /home/user/caffe-master/data/DL/train/p24118.jpg
.
.
.
你可以帮我知道我在哪里做错了吗??!?!

1 个答案:

答案 0 :(得分:1)

问题是我的图像是uint16位图!!但是,经过大量搜索,我发现caffe适用于uint8位图