首先,问题来自caffe学习系列(12):http://www.cnblogs.com/denny402/p/5082341.html
按照该博客中的教程,在caffe目录下执行:
# sudo vi examples/images/create_filelist.sh
vi表示打开或者新建一个文件,最好先看一下linux基本指令vi的用法。
用vi新建。.sh文件后,按“i”进入编辑模式,复制博客中提到的代码:
# /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.."
按ESC退出编辑模式,按“:wq!"退出vi并保存。此时,在caffe/examples/images目录下会生成create_filelist.sh文件
运行:cd caffe/examples/images
sudo sh create_filelist.sh
运行后会出现以下错误:
Create train.txt...
create_filelist.sh: 5: create_filelist.sh: cannot create examples/images/train.txt: Directory nonexistent
find: `examples/images': No such file or directory
create_filelist.sh: 6: create_filelist.sh: cannot create examples/images/tmp.txt: Directory nonexistent
find: `examples/images': No such file or directory
create_filelist.sh: 7: create_filelist.sh: cannot create examples/images/train.txt: Directory nonexistent
Done..
此时,需要更改图片路径:
DATA=examples/images -->DATA=/home/xxx/caffe/examples/images 注:xxx是自己电脑名称,如tony重新执行:cd caffe/examples/imagessudo sh create_filelist.sh此时会在caffe/examples/images目录下会生成train.txt,但是打开会发现内容是错误的:xxx 1xxx 2此时需要将: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更改为:此时运行.sh,结果应该正确。find $DATA -name *cat.jpg | cut -d '/' -f7 | sed "s/$/ 1/">>$DATA/train.txt find $DATA -name *bike.jpg | cut -d '/' -f7 | sed "s/$/ 2/">>$DATA/tmp.txt