使用Faster R-CNN训练自己的数据_NWPU_VHR-10数据集
2017-12-18 16:21
701 查看
本文转自:初沏的茶 http://blog.csdn.net/chuqidecha/article/details/58148611
1. 主要步骤
VOC2007格式数据集制作训练集均值文件计算
网络选择
faster r-cnn源码修改
运行
2. VOC2007格式数据集制作
1. 修改VOCinit.m
(1) 数据集名称第12行VOC2007改为自己的文件夹名称
VOCopts.dataset='your folder name'1
(2) 修改图片格式
第37行中的jpg换成自己的图片格式
VOCopts.imgpath=[VOCopts.datadir VOCopts.dataset '/JPEGImages/%s.jpg'];1
(3) 修改标签名称
第81行之后的类别名称换成自己数据集的类别名称
VOCopts.classes={... 'cls1' 'cls2' ... 'clsn' };1
2
3
4
5
6
3. 文件目录
按照下图添加文件夹,其中的NWPU_VHR-10改为自己的数据集名称。
3. xml格式的annotation文件
4. 数据集划分
在/NWPU_VHR-10/ImageSets/Main文件夹下创建test.txt、train.txt、trainval.txt、val.txt四个文件,分别保存测试集、训练集、训练集-验证集合验证集。每个文件名占一行,不包含后缀名。
2. 计算图片数据的均值
windows下计算图片数据均值使用的工具和命令与Linux下的相同。可参照@denny402的博客–计算图片数据的均值。工具生成的格式是binaryproto格式的文件,MATLAB中使用的是mat格式文件,使用caffe.io.read_mean进行格式转换。image_mean = caffe.io.read_mean('path to mean file'); save('path to save','image_mean');1
2
3
4. 网络选择与参数修改
对于ZF网络,训练Fast R-CNN需要至少3G现存,根据自己的硬件配置,选择合适的网络,然后对网络参数进行修改。
1. models\ fast_rcnn_prototxts\ZF\ train_val.prototxt
input: "bbox_targets" input_dim: 1 # to be changed on-the-fly to match num ROIs input_dim: 84 # 根据类别数改,该值为(类别数+1)*4 input_dim: 1 input_dim: 11
2
3
4
5
input: "bbox_loss_weights" input_dim: 1 # to be changed on-the-fly to match num ROIs input_dim: 84 # 根据类别数改,该值为(类别数+1)*4 input_dim: 1 input_dim: 11
2
3
4
5
layer { bottom: "fc7" top: "cls_score" name: "cls_score" param { lr_mult: 1.0 } param { lr_mult: 2.0 } type: "InnerProduct" inner_product_param { num_output: 21 #根据类别数改该值为类别数+1 weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 0 } } }1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
layer { bottom: "fc7" top: "bbox_pred" name: "bbox_pred" type: "InnerProduct" param { lr_mult: 1.0 } param { lr_mult: 2.0 } inner_product_param { num_output: 84 # 根据类别数改,该值为(类别数+1)*4 weight_filler { type: "gaussian" std: 0.001 } bias_filler { type: "constant" value: 0 } } }1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2. models\ fast_rcnn_prototxts\ZF\ test.prototxt
layer { bottom: "fc7" top: "cls_score" name: "cls_score" param { lr_mult: 1.0 } param { lr_mult: 2.0 } type: "InnerProduct" inner_product_param { num_output: 21 #根据类别数改该值为类别数+1 weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 0 } } }1
layer { bottom: "fc7" top: "bbox_pred" name: "bbox_pred" type: "InnerProduct" param { lr_mult: 1.0 } param { lr_mult: 2.0 } inner_product_param { num_output: 84 # 根据类别数改,该值为(类别数+1)*4 weight_filler { type: "gaussian" std: 0.001 } bias_filler { type: "constant" value: 0 } } }
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
3. 其他文件
models\ fast_rcnn_prototxts\ZF6\ train_val.prototxt与models\ fast_rcnn_prototxts\ZF\ train_val.prototxt修改的地方相同。 models\ fast_rcnn_prototxts\ZF6\ test.prototxt与 models\ fast_rcnn_prototxts\ZF\ test.prototxt修改的地方相同
5. faster r-cnn源码修改
1. function\fast_rcnn\fast_rcnn_train.m
ip.addParamValue('val_iters', 500, @isscalar);1
val_iters的默认值设置为验证样本数的1/5左右,最大不能超过验证样本数。
2. function\rpn\proposal_train.m
与fast_rcnn_train.m相同,修改val_iters值。
3. imdb\imdb_eval_voc.m
%注释73行 %do_eval = (str2num(year) <= 2007) | ~strcmp(test_set,'test'); %添加下面语句 do_eval = 1;1
2
3
4
如果不修改,测试时精度全为0。
4. experiments+Model\ZF_for_Faster_RCNN_VOC2007.m
在该文件中修改faster-rcnn各阶段训练时的参数
5. 运行
运行experiments/script_faster_rcnn_VOC2007_ZF.m。运行结束后根据提示修改detection_test.prototxt
相关文章推荐
- 使用faster rcnn训练自己的数据-制作数据集
- 使用faster rcnn训练自己的数据(py-faster-rcnn )
- 使用Faster R-CNN训练自己的数据
- mxnet 使用自己的图片数据训练CNN模型
- Tensorflow + ResNet101 + fasterRcnn 训练自己的模型 数据(一)
- py-faster-rcnn+cpu配置并训练自己的数据
- 使用py-faster-rcnn训练自己的数据
- faster r-cnn训练自己的数据
- FasterRCNN训练自己数据记载
- 使用faster rcnn训练imageNet上的部分数据集
- ubuntu 系统下使用Fast rcnn 训练自己数据
- faster rcnn 训练自己的数据(python)
- py-faster-rcnn + ZF 实现自己的数据训练与检测(二)
- Faster RCNN训练自己的数据 Matlab【实验记录】
- py-faster-rcnn + ZF 实现自己的数据训练与检测(一)
- py-faster-rcnn + ZF 实现自己的数据训练与检测(二)
- 使用caffe框架利用faster-rcnn来训练自己的数据集
- [深度学习] RCNNs系列(1) Ubuntu下Faster RCNN配置及训练和测试自己的数据方法
- faster rcnn 训练自己的数据
- [深度学习] RCNNs系列(1) Ubuntu下Faster RCNN配置及训练和测试自己的数据方法