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内心一直没放弃,但从现状来看,需要 ...
随机推荐
- DotNetty的通道处理细节
第一,客户端如何向服务器主动发送消息: 第二,服务器如何向指定客户端发送消息: 第三,在哪里做报文的拆包和组包. public partial class FrmMain : Form { publi ...
- jQuery Ajax方式上传文件实现暂停或取消上传
未上传时要实现取消,很简单... 但如果用户点击了上传,并加载了进度信息... 2017-05-04再次改进.在上传过程中用户可以按 Esc 来取消上传(取消当前上传,或者是全部上传)... 也可以在 ...
- Fix "Drives are running out of free space" Error in SharePoint Health Analyzer
前言 最近帮助用户做健康检查,用户发现事件查看器(EventView)里面有很多错误,有一个就是"Drives are running out of free space",而且每 ...
- 蓝精灵:寻找神秘村Smurfs: The Lost Village迅雷下载
蓝妹妹(黛米·洛瓦托 Demi Lovato 配音)发现了一张遗落的地图,由此引发精灵们对于神秘村庄真实性的猜想.于是,满怀好奇心的蓝妹妹与聪聪(丹尼·朴迪 Danny Pudi 配音).笨笨(杰克· ...
- jquery入门 改动网页背景颜色
我们在浏览一些站点,尤其是一些小说站点的时候,都会有改动页面背景颜色的地方,这个功能使用jquery非常easy实现. 效果图: show you code: <!doctype html> ...
- 实用ExtJS教程100例-008:使用iframe填充ExtJS Window组件
上面两节中我们分别演示了ExtJS Window的常用功能 和 如何最小化ExtJS Window组件,在这篇内容中我们来演示一下如何使用iframe填充window组件. 思路很简单,首先创建一个w ...
- Pandas 快速入门(二)
本文的例子需要一些特殊设置,具体可以参考 Pandas快速入门(一) 数据清理和转换 我们在进行数据处理时,拿到的数据可能不符合我们的要求.有很多种情况,包括部分数据缺失,一些数据的格式不正确,一些数 ...
- 浅谈Java Future接口
Java项目编程中,为了充分利用计算机CPU资源,一般开启多个线程来执行异步任务.但不管是继承Thread类还是实现Runnable接口,都无法获取任务执行的结果.JDK 5中引入了Callable和 ...
- Java多线程知识-Callable和Future
Callable和Future出现的原因 创建线程的2种方式,一种是直接继承Thread,另外一种就是实现Runnable接口. 这2种方式都有一个缺陷就是:在执行完任务之后无法获取执行结果. 如果需 ...
- C#中的命名空间namespace与Java中的包package之间的区别
Java 包被用来组织文件或公共类型以避免类型冲突.包结构可以映射到文件系统. System.Security.Cryptography.AsymmetricAlgorithm aa; 可能被替换: ...