FasterRcnn训练数据集参数配置
说明:本博文假设你已经做好了自己的数据集,该数据集格式和VOC2007相同。做好数据集后,我们开始训练,下面是训练前的一些修改。
本文来自:http://www.lai18.com/content/2526443.html
1 、VOCdevkit2007\VOCcode\VOCinit.m的修改
(1)路径的修改
- VOCopts.annopath=[VOCopts.datadir VOCopts.dataset '/Annotations/%s.xml'];
- VOCopts.imgpath=[VOCopts.datadir VOCopts.dataset '/JPEGImages/%s.jpg'];
- VOCopts.imgsetpath=[VOCopts.datadir VOCopts.dataset '/ImageSets/Main/%s.txt'];
- VOCopts.clsimgsetpath=[VOCopts.datadir VOCopts.dataset '/ImageSets/Main/%s_%s.txt'];
- VOCopts.clsrespath=[VOCopts.resdir 'Main/%s_cls_' VOCopts.testset '_%s.txt'];
- VOCopts.detrespath=[VOCopts.resdir 'Main/%s_det_' VOCopts.testset '_%s.txt'];
上面这些路径要正确,第一个是xml标签路径;第二个是图片的路径;第三个是放train.txt、val.txt、test.txt和trainval.txt的路径;第四、五、六个不需要;一般来说这些路径不用修改,你做的数据集格式和VOC2007相同就行。
(2)训练集文件夹修改
- VOCopts.dataset = '你的文件夹名';
然后将VOC2007路径注释掉,上面“你的文件夹名”是你放Annotations、ImageSets、JPEGImages文件夹的文件夹名。
(3)标签的修改
- VOCopts.classes={...
- '你的标签1'
- '你的标签2'
- '你的标签3'
- '你的标签4'};
将其改为你的标签。
2 、VOCdevkit2007\results
results下需要新建一个文件夹,名字和xml中的<folder>***</folder>对应。***文件夹下新建一个Main文件夹。
3 、VOCdevkit2007\local
local下需要新建一个文件夹,名字和xml中的<folder>***</folder>对应。
4 、function\fast_rcnn\fast_rcnn_train.m
- ip.addParamValue('val_iters', 500, @isscalar);
- ip.addParamValue('val_interval', 2000, @isscalar);
可能在randperm(N,k)出现错误,可以将500改小点,比如200.
5、function\rpn\proposal_train.m
这里的问题和fast_rcnn_train.m一样。
6.imdb\imdb_eval_voc.m
- %do_eval = (str2num(year) <= 2007) | ~strcmp(test_set,'test');
- do_eval = 1;
注释掉
- do_eval = (str2num(year) <= 2007) | ~strcmp(test_set,'test');
并令其为1,否则测试会出现精度全为0的情况
7. imdb\roidb_from_voc.m
- ip.addParamValue('exclude_difficult_samples', true, @islogical);</span>
不包括难识别的样本,所以设置为true。(如果有就设置为false)
8.网络模型的修改
(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: 1
- input: "bbox_loss_weights"
- input_dim: 1 # to be changed on-the-fly to match num ROIs
- input_dim: 84 # 根据类别数改,该值为(类别数+1)*4 ############</span>
- input_dim: 1
- input_dim: 1
- 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 #########
- 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 ##########
(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 ##########
- 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 #4*(类别数+1) ##########
(3) models\ fast_rcnn_prototxts\ZF_fc6\ train_val.prototxt
- input: "bbox_targets"
- input_dim: 1 # to be changed on-the-fly to match num ROIs
- input_dim: 84 # 4*(类别数+1) ###########
- input_dim: 1
- input_dim: 1
- input: "bbox_loss_weights"
- input_dim: 1 # to be changed on-the-fly to match num ROIs
- input_dim: 84 # 4*(类别数+1) ###########
- input_dim: 1
- input_dim: 1
- 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 ############
- 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 #4*(类别数+1) ###########
(4) models\ fast_rcnn_prototxts\ZF_fc6\ 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 #######
- 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 #4*(类别数+1) ##########
!!!为防止与之前的模型搞混,训练前把output文件夹删除(或改个其他名),还要把imdb\cache中的文件删除(如果有的话)
9.开始训练
运行:
- experiments/script_faster_rcnn_VOC2007_ZF.m
10.训练完后
训练完后,不要急着马上测试,先打开output/faster_rcnn_final/faster_rcnn_VOC2007_ZF文件夹,打开detection_test.prototxt,作如下修改:
将relu5(包括relu5)前的层删除,并将roi_pool5的bottom改为data和rois。并且前面的input_dim:分别改为1,256,50,50(如果是VGG就是1,512,50,50,其他修改基本一样),具体如下
- input: "data"
- input_dim: 1
- input_dim: 256
- input_dim: 50
- input_dim: 50
- # ------------------------ layer 1 -----------------------------
- layer {
- bottom: "data"
- bottom: "rois"
- top: "pool5"
- name: "roi_pool5"
- type: "ROIPooling"
- roi_pooling_param {
- pooled_w: 6
- pooled_h: 6
- spatial_scale: 0.0625 # (1/16)
- }
- }
11.测试
训练完成后,打开\experiments\script_faster_rcnn_demo.m,将模型路径改成训练得到的模型路径:
- model_dir = fullfile(pwd, 'output', 'faster_rcnn_final', 'faster_rcnn_VOC2007_ZF')
- 将测试图片改成你的图片,im_names = {'001.jpg', '002.jpg', '003.jpg'};
FasterRcnn训练数据集参数配置的更多相关文章
- yolo训练数据集
最近了解了下yolov3的训练数据集部分,总结了以下操作步骤:(基于pytorch框架,请预先装好pytorch的相关组件) 1.下载ImageLabel软件对图片进行兴趣区域标记,每张图片对应一个x ...
- 从零搭建Pytorch模型教程(四)编写训练过程--参数解析
前言 训练过程主要是指编写train.py文件,其中包括参数的解析.训练日志的配置.设置随机数种子.classdataset的初始化.网络的初始化.学习率的设置.损失函数的设置.优化方式的设置. ...
- pytorch和tensorflow的爱恨情仇之定义可训练的参数
pytorch和tensorflow的爱恨情仇之基本数据类型 pytorch和tensorflow的爱恨情仇之张量 pytorch版本:1.6.0 tensorflow版本:1.15.0 之前我们就已 ...
- Hi3559AV100 NNIE开发(3)RuyiStudio软件 .wk文件生成过程-mobilefacenet.cfg的参数配置
之后随笔将更多笔墨着重于NNIE开发系列,下文是关于Hi3559AV100 NNIE开发(3)RuyiStudio软件 .wk文件生成过程-mobilefacenet.cfg的参数配置,目前项目需要对 ...
- 转:浅谈UNIX下Apache的MPM及httpd.conf配置文件中相关参数配置
为什么要并发处理 以Apache为代表的web服务器中,如果不支持并发,则在一个客户端连接的时候,如果该客户端的任务没有处理完,其他连接的客户端将会一直处于等待状态,这事不可想象的,好像没有为什么要不 ...
- Spark on Yarn:任务提交参数配置
当在YARN上运行Spark作业,每个Spark executor作为一个YARN容器运行.Spark可以使得多个Tasks在同一个容器里面运行. 以下参数配置为例子: spark-submit -- ...
- Production环境中iptables常用参数配置
production环境中iptables常用参数配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 我相信在实际生产环境中有很多运维的兄弟跟我一样,很少用到iptables的这个 ...
- Unity3D安卓打包参数配置与兼容性的关系分析
前言 在使用Unity3D工程导出安卓安装包的时候,往往会遇到兼容性的问题,针对某些机型,要么无法打开游戏,要么会出现卡机的现象.面对这种情况,我们可以调节相关的参数来提高兼容性. 为了了解在打包时候 ...
- 教你如何利用分布式的思想处理集群的参数配置信息——spring的configurer妙用
引言 最近LZ的技术博文数量直线下降,实在是非常抱歉,之前LZ曾信誓旦旦的说一定要把<深入理解计算机系统>写完,现在看来,LZ似乎是在打自己脸了.尽管LZ内心一直没放弃,但从现状来看,需要 ...
随机推荐
- 基于jQuery的判断iPad、iPhone、Android是横屏还是竖屏的代码
在ipad.iphone网页开发中,我们很可能需要判断是横屏或者竖屏.下面就来介绍如何用 jQuery 判断iPad.iPhone.Android是横屏还是竖屏的方法 其实主要是通过window.or ...
- 破产姐妹第一季/全集2 Broke Girls迅雷下载
本季2 Broke Girls Season 1 (2011)看点:黑发泼辣的Max(凯特·戴琳斯 Kat Dennings 饰)在纽约布鲁克林区一家低档餐馆打工,餐馆同事包括小个子亚裔老板Han L ...
- 抄袭证据之中的一个CMM与CMMI的名称
以下文字来自我即将完毕的文章,谢博士说她没有抄袭,可是文中实在是有太多的漏洞了. 6.2.7 P120页中: "实际上终于所谓的统一方法论就是标准,尽管作标准并非目的.但标准是必须有的.能够 ...
- endnote插入参考文献后的对齐方式和缩进空格
原文链接 https://jingyan.baidu.com/article/63acb44a3f0f6161fcc17ed0.html 1 2 3 4 5 6 7 分步阅读 1.endnote 导入 ...
- golang常用模块介绍
golang模块 一.命令行库Cobra Cobra提供简单的接口来创建强大的现代化CLI接口,比如git与go工具.Cobra同时也是一个程序, 用于创建CLI程序 https://www.jian ...
- Dapper,大规模分布式系统的跟踪系统
概述 当代的互联网的服务,通常都是用复杂的.大规模分布式集群来实现的.互联网应用构建在不同的软件模块集上,这些软件模块,有可能是由不同的团队开发.可能使用不同的编程语言来实现.有可能布在了几千台服务器 ...
- poj 4468Spy(kmp算法)
Spy Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submis ...
- C++ 内置宏定义 与 预编译指令
内置宏和预编译指令, 在代码调试.单元测试.跨平台代码中经常会用到.这里记录一下. 1. 内置宏 (文件名,当前行号,当前日期,当前时间,当前执行方法名) __FILE____LINE____DATE ...
- HttpWebRequest 对象池 HTTP协议 HttpWebRequest和 Socket的一点总结
相信接触过网络开发的人对HTTP.HttpWebRequest.Socket这些东西都不陌生吧.它们之间的一些介绍和关系我这里都忽略了.开我们平时开发过程中也是很少有机会接触大什么大并发这个东东,一般 ...
- [leetcode]Rotate Image @ Python
原题地址:https://oj.leetcode.com/problems/rotate-image/ 题意: You are given an n x n 2D matrix representin ...