配置环境参照我的上一篇博文,整个测试过程是在网上爬出来并亲自实践总结,中间遇到的各种问题已详细po出,供大家交流学习。
===================================================================
参考链接1:http://www.cnblogs.com/denny402/p/5083300.html(内提供楼主整理的图片集)
参考链接2:http://blog.youkuaiyun.com/abc8730866/article/details/52556286
参考链接3:http://www.cnblogs.com/qw12/p/6160572.html
我将自己制作的图片集共享:
针对参考链接1:
百度云:链接:http://pan.baidu.com/s/1gf65eqJ 密码:sxfl
针对参考链接2:
百度云:链接:http://pan.baidu.com/s/1qXQVpSC 密码:esyp
-------------------------1.制作txt文档----------------------------
统一图片大小,给出txt格式,以train.txt为例:
训练集(图片集)路径:.\caffe-master\data\myfile\train
train.txt文件路径:.\caffe-master\examples\myfile
train.txt文件格式形如:
001.jpg 1
(格式:001.jpg为图片名称,(中间有空格),1为类别)
------------------------2.转换成Lmdb数据格式-----------------------
windows下数据的格式转换:
http://blog.youkuaiyun.com/abc8730866/article/details/52488813
参考链接:http://blog.youkuaiyun.com/dsif1995/article/details/51793986
cmd命令如下($符号不要):
$cd C:\Users\DELL\Desktop\caffe-master(3)\caffe-master\Build\x64\Release
$convert_imageset.exe
$convert_imageset C:\Users\DELL\Desktop\caffe-master(3)\caffe-master\data\ownfile\train\ C:\Users\DELL\Desktop\caffe-master(3)\caffe-master\examples\ownfile\train.txt C:\Users\DELL\Desktop\caffe-master(3)\caffe-master\examples\ownfile\train_lmdb
(格式:convert_imageset 图片集存放路径 txt文件路径+名称 生成的lmdb文件路径)
------------------------3.求图像数据的均值-------------------------
参考链接:http://blog.youkuaiyun.com/hong__fang/article/details/52425105
cmd命令如下:
$cd C:\Users\DELL\Desktop\caffe-master(3)\caffe-master\Build\x64\Release
$compute_image_mean.exe
$compute_image_mean C:\Users\DELL\Desktop\caffe-master(3)\caffe-master\examples\ownfile\train_lmdb C:\Users\DELL\Desktop\caffe-master(3)\caffe-master\examples\ownfile\train_mean.binaryproto
(格式:compute_image_mean 输入lmdb文件夹 输出均值文件(所在位置及文件名称,后缀))
出现compute_image_mean.exe已停止工作,参考链接:http://www.mamicode.com/info-detail-1459540.html
--------------4.采用bvlc_reference_caffenet模型训练数据---------------
参考链接:http://blog.youkuaiyun.com/hong__fang/article/details/52425105
辅助软件:可下载Notepad++软件打开.prototxt文件
网络定义及设置:
(注1:以下路径都是绝对路径)——不一定,若报错可用这招试试(自己用这招解决过bug)
(注2:路径一定要使用/,而不能是\)——不一定,若报错可用这招试试
①打开train_val.prototxt文件:
修改train的mean_file路径(均值文件(路径,文件名),行号13),source路径(lmdb文件(路径,文件名),行号24)
修改test的mean_file路径(均值文件,行号40),source路径(lmdb文件,行号51)
不要修改输出层num_output——这个依具体情况而定,目前我自己试了两个数据集,按照自己的类别数改了以后会出现bug:准确率一直不变,而且很低。
②打开solver.prototxt文件(solver是caffe核心的核心):
关于solver设置的一些问题:http://blog.youkuaiyun.com/sherry_gp/article/details/50935231
修改net:采用的网络train_val.prototxt文件路径(带文件名)。
-------------------------5.Caffe.exe网络训练-----------------------
caffe格式:http://www.cnblogs.com/denny402/p/5076285.html
cmd命令如下:
$cd C:\Users\DELL\Desktop\caffe-master(3)\caffe-master
$Build\x64\Release\caffe.exe train -solver models\bvlc_reference_caffenet\solver.prototxt
Build\x64\Release\caffe.exe train -solver examples\ownfile\solver.prototxt