caffe一定要编译通过!!!才能进行下面操作
一、在 caffe 根目录 下创建自己的文件夹My_Files
其中,train 文件夹里包含训练图片和训练图片的 labels.txt;
二、训练集和label.txt
lable.txt 中图片id 与标签用 空格 隔开
三、create_imagenet.sh
将 /examples/imagenet/create_imagenet.sh 复制到该文件夹下进行修改,进行训练和测试路径的设置,终端运行./My_Files/create_imagenet.sh
#!/usr/bin/env sh
# Create the imagenet lmdb inputs
# N.B. set the path to the imagenet train + val data dirs
set -e
EXAMPLE=My_Files/ #create_imagenet.sh所在文件夹
DATA=My_Files/train/ #lable.txt 所在文件夹
TOOLS=build/tools #不能修改,convert_imageset所在文件夹
TRAIN_DATA_ROOT=My_Files/train/ #训练数据所在文件夹
VAL_DATA_ROOT=My_Files/val/ #验证数据所在文件夹
# Set RESIZE=true to resize the images to 256x256. Leave as false if images have
# already been resized using another tool.
RESIZE=false
if $RESIZE; then
RESIZE_HEIGHT=256
RESIZE_WIDTH=256
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_imagenet.sh to the path" \
"where the ImageNet 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_imagenet.sh to the path" \
"where the ImageNet 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 \
$TRAIN_DATA_ROOT \
$DATA/train.txt \
$EXAMPLE/dogs_train_lmdb
#echo "Creating val lmdb..."
#GLOG_logtostderr=1 $TOOLS/convert_imageset \
# --resize_height=$RESIZE_HEIGHT \
# --resize_width=$RESIZE_WIDTH \
# --shuffle \
# $VAL_DATA_ROOT \
# $DATA/val.txt \
# $EXAMPLE/ilsvrc12_val_lmdb
echo "Done."
参考博客http://blog.csdn.net/liuweizj12/article/details/52149743