原图像数据:
首先必须熟悉一下,find,cut,sed 命令的使用。
# /usr/bin/env sh
DATA=examples/images #数据目录
echo "Create train.txt..."
rm -rf $DATA/train.txt
find $DATA -name *cat.jpg | cut -d '/' -f3 | sed "s/$/ 1/">>$DATA/train.txt
find $DATA -name *bike.jpg | cut -d '/' -f3 | sed "s/$/ 2/">>$DATA/tmp.txt
cat $DATA/tmp.txt>>$DATA/train.txt
rm -rf $DATA/tmp.txt
echo "Done.."
在caffe根目录下运行:
$ ./examples/images/creat_picturelist.sh
运行结果:
此时,配置文件的数据输入层改:
layer {
name: "Data"
type: "ImageData"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {
scale: 0.00390625
}
image_data_param{
source:"/home/xxx/caffe/examples/train.txt"
shuffle : true
batch_size: 20
new_height: 141
new_width: 141
}
}
打完,手工!