您的位置:首页 > Web前端

caffe系列学习博客网址

2017-12-07 16:13 483 查看
http://www.cnblogs.com/denny402/category/759199.html

根据这个教程里面还有需要注意的地方:

(1)(在creatfile_list.sh)文件中,path,data,my 这些路径一定不要写错了。

(2222) 还有就是如果你的图片不是以数字开头,也许需要改下

find $DATA/train -name "p*.bmp" | cut -d '/' -f4-5 | sed "s/$/ 0/">>$MY/train.txt
find $DATA/train -name "i*.bmp" | cut -d '/' -f4-5 | sed "s/$/ 1/">>$MY/train.txt


在train_val.prototxt文件根据修改后,如果你的分类不需要1000个,应该经下面的num_outpot改为相应的分类数量,同时从modeld文件夹下的bvlc_reference_caffenet文件下下复制deploy文件,因为你之前的sovel和train.val都是从这里复制的,因此需要从这里复制。并且也要修改里面的num_output。同时synsets.txt文件不需要1000行,仅仅留下你分类的行数,并标上名字。

layer {
name: "fc8"
type: "InnerProduct"
bottom: "fc7"
top: "fc8"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 2
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}


(2)在开始训练的时候会出现restart data 这类命令,不要在意,让他自己慢慢运行就行,不用管。

按照教程执行后会生成model文件,就在caffe根目录下。以iterationxxx.model名字

还有下面的需要做:

deploy.prototxt自己复制并且改:

https://www.cnblogs.com/k7k8k91/p/7806232.html

同时记得这个修改一定要参照原来的东西,在dim dim dim dim 后面两个dim记得参照修改前的数值(227,227),不是256,也不是图像的实际大小。

之后还有一个文件叫synsets.txt

这个文件一定是需要的。

n01440764 car
n01443537 konglong
n01484850 daxiang
n01491361 hua
n01494475 ma
n01496331 6
n01498041
n01514668
n01514859
n01518878
n01530575
n01531178
n01532829
n01534433
n01537544
n01558993
n01560419
n01580077
n01582220
n01592084
n01601694
n01608432
n01614925
n01616318
n01622779
n01629819


由于原来的网络层的定义你最后的输出是1000,所以你的这个文件一定要有1000行,当然我们自己训练肯定是不需要分1000类的,我们仅仅需要根据你的图片分类顺序填上你的分类名称就好,多余的可以空着不填。

训练命令:

sudo build/tools/caffe train -solver examples/myfile/solver.prototxt


模型训练好后需要测试:

sudo ./build/examples/cpp_classification/classification.bin
examples/myfile2/deploy.prototxt _iter_920.caffemodel
examples/myfile2/mean.binaryproto
examples/myfile2/synsets.txt data/re2/test/pic291.bmp
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: