说明:本博文假设你已经做好了自己的数据集,该数据集格式和VOC2007相同。做好数据集后,我们开始训练,下面是训练前的一些修改。
本文来自:http://www.lai18.com/content/2526443.html

1 、VOCdevkit2007\VOCcode\VOCinit.m的修改

(1)路径的修改

  1. VOCopts.annopath=[VOCopts.datadir VOCopts.dataset '/Annotations/%s.xml'];
  2. VOCopts.imgpath=[VOCopts.datadir VOCopts.dataset '/JPEGImages/%s.jpg'];
  3. VOCopts.imgsetpath=[VOCopts.datadir VOCopts.dataset '/ImageSets/Main/%s.txt'];
  4. VOCopts.clsimgsetpath=[VOCopts.datadir VOCopts.dataset '/ImageSets/Main/%s_%s.txt'];
  5. VOCopts.clsrespath=[VOCopts.resdir 'Main/%s_cls_' VOCopts.testset '_%s.txt'];
  6. VOCopts.detrespath=[VOCopts.resdir 'Main/%s_det_' VOCopts.testset '_%s.txt'];

上面这些路径要正确,第一个是xml标签路径;第二个是图片的路径;第三个是放train.txt、val.txt、test.txt和trainval.txt的路径;第四、五、六个不需要;一般来说这些路径不用修改,你做的数据集格式和VOC2007相同就行。

(2)训练集文件夹修改

  1. VOCopts.dataset = '你的文件夹名';

然后将VOC2007路径注释掉,上面“你的文件夹名”是你放Annotations、ImageSets、JPEGImages文件夹的文件夹名。

(3)标签的修改

  1. VOCopts.classes={...
  2. '你的标签1'
  3. '你的标签2'
  4. '你的标签3'
  5. '你的标签4'};

将其改为你的标签。

2 、VOCdevkit2007\results

results下需要新建一个文件夹,名字和xml中的<folder>***</folder>对应。***文件夹下新建一个Main文件夹。

3 、VOCdevkit2007\local

local下需要新建一个文件夹,名字和xml中的<folder>***</folder>对应。

4 、function\fast_rcnn\fast_rcnn_train.m

  1. ip.addParamValue('val_iters',       500,            @isscalar);
  2. 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

  1. %do_eval = (str2num(year) <= 2007) | ~strcmp(test_set,'test');
  2. do_eval = 1;

注释掉

  1. do_eval = (str2num(year) <= 2007) | ~strcmp(test_set,'test');

并令其为1,否则测试会出现精度全为0的情况

7. imdb\roidb_from_voc.m

  1. ip.addParamValue('exclude_difficult_samples',       true,   @islogical);</span>

不包括难识别的样本,所以设置为true。(如果有就设置为false)

8.网络模型的修改

(1) models\ fast_rcnn_prototxts\ZF\ train_val.prototxt

  1. input: "bbox_targets"
  2. input_dim: 1  # to be changed on-the-fly to match num ROIs
  3. input_dim: 84 # 根据类别数改,该值为(类别数+1)*4  #################
  4. input_dim: 1
  5. input_dim: 1
  1. input: "bbox_loss_weights"
  2. input_dim: 1  # to be changed on-the-fly to match num ROIs
  3. input_dim: 84 # 根据类别数改,该值为(类别数+1)*4   ############</span>
  4. input_dim: 1
  5. input_dim: 1
  1. layer {
  2. bottom: "fc7"
  3. top: "cls_score"
  4. name: "cls_score"
  5. param {
  6. lr_mult: 1.0
  7. }
  8. param {
  9. lr_mult: 2.0
  10. }
  11. type: "InnerProduct"
  12. inner_product_param {
  13. num_output: 21 #根据类别数改该值为类别数+1   #########
  1. layer {
  2. bottom: "fc7"
  3. top: "bbox_pred"
  4. name: "bbox_pred"
  5. type: "InnerProduct"
  6. param {
  7. lr_mult: 1.0
  8. }
  9. param {
  10. lr_mult: 2.0
  11. }
  12. inner_product_param {
  13. num_output: 84  #根据类别数改,该值为(类别数+1)*4  ##########

(2) models\ fast_rcnn_prototxts\ZF\ test.prototxt

  1. layer {
  2. bottom: "fc7"
  3. top: "cls_score"
  4. name: "cls_score"
  5. param {
  6. lr_mult: 1.0
  7. }
  8. param {
  9. lr_mult: 2.0
  10. }
  11. type: "InnerProduct"
  12. inner_product_param {
  13. num_output: 21  #类别数+1  ##########
  1. layer {
  2. bottom: "fc7"
  3. top: "bbox_pred"
  4. name: "bbox_pred"
  5. type: "InnerProduct"
  6. param {
  7. lr_mult: 1.0
  8. }
  9. param {
  10. lr_mult: 2.0
  11. }
  12. inner_product_param {
  13. num_output: 84  #4*(类别数+1)  ##########

(3) models\ fast_rcnn_prototxts\ZF_fc6\ train_val.prototxt

  1. input: "bbox_targets"
  2. input_dim: 1  # to be changed on-the-fly to match num ROIs
  3. input_dim: 84 # 4*(类别数+1)  ###########
  4. input_dim: 1
  5. input_dim: 1
  1. input: "bbox_loss_weights"
  2. input_dim: 1  # to be changed on-the-fly to match num ROIs
  3. input_dim: 84 # 4*(类别数+1)  ###########
  4. input_dim: 1
  5. input_dim: 1
  1. layer {
  2. bottom: "fc7"
  3. top: "cls_score"
  4. name: "cls_score"
  5. param {
  6. lr_mult: 1.0
  7. }
  8. param {
  9. lr_mult: 2.0
  10. }
  11. type: "InnerProduct"
  12. inner_product_param {
  13. num_output: 21 #类别数+1   ############
  1. layer {
  2. bottom: "fc7"
  3. top:"bbox_pred"
  4. name:"bbox_pred"
  5. type:"InnerProduct"
  6. param {
  7. lr_mult:1.0
  8. }
  9. param {
  10. lr_mult:2.0
  11. }
  12. inner_product_param{
  13. num_output: 84   #4*(类别数+1)   ###########

(4) models\ fast_rcnn_prototxts\ZF_fc6\ test.prototxt

  1. layer {
  2. bottom: "fc7"
  3. top: "cls_score"
  4. name: "cls_score"
  5. param {
  6. lr_mult: 1.0
  7. }
  8. param {
  9. lr_mult: 2.0
  10. }
  11. type: "InnerProduct"
  12. inner_product_param {
  13. num_output: 21  类别数+1 #######
  1. layer {
  2. bottom: "fc7"
  3. top: "bbox_pred"
  4. name: "bbox_pred"
  5. type: "InnerProduct"
  6. param {
  7. lr_mult: 1.0
  8. }
  9. param {
  10. lr_mult: 2.0
  11. }
  12. inner_product_param {
  13. num_output: 84  #4*(类别数+1) ##########

!!!为防止与之前的模型搞混,训练前把output文件夹删除(或改个其他名),还要把imdb\cache中的文件删除(如果有的话)

9.开始训练

运行:

  1. 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,其他修改基本一样),具体如下

  1. input: "data"
  2. input_dim: 1
  3. input_dim: 256
  4. input_dim: 50
  5. input_dim: 50
  1. # ------------------------ layer 1 -----------------------------
  2. layer {
  3. bottom: "data"
  4. bottom: "rois"
  5. top: "pool5"
  6. name: "roi_pool5"
  7. type: "ROIPooling"
  8. roi_pooling_param {
  9. pooled_w: 6
  10. pooled_h: 6
  11. spatial_scale: 0.0625  # (1/16)
  12. }
  13. }

11.测试

训练完成后,打开\experiments\script_faster_rcnn_demo.m,将模型路径改成训练得到的模型路径:

  1. model_dir                   = fullfile(pwd, 'output', 'faster_rcnn_final', 'faster_rcnn_VOC2007_ZF')
    1. 将测试图片改成你的图片,im_names = {'001.jpg', '002.jpg', '003.jpg'};

FasterRcnn训练数据集参数配置的更多相关文章

  1. yolo训练数据集

    最近了解了下yolov3的训练数据集部分,总结了以下操作步骤:(基于pytorch框架,请预先装好pytorch的相关组件) 1.下载ImageLabel软件对图片进行兴趣区域标记,每张图片对应一个x ...

  2. 从零搭建Pytorch模型教程(四)编写训练过程--参数解析

    ​  前言 训练过程主要是指编写train.py文件,其中包括参数的解析.训练日志的配置.设置随机数种子.classdataset的初始化.网络的初始化.学习率的设置.损失函数的设置.优化方式的设置. ...

  3. pytorch和tensorflow的爱恨情仇之定义可训练的参数

    pytorch和tensorflow的爱恨情仇之基本数据类型 pytorch和tensorflow的爱恨情仇之张量 pytorch版本:1.6.0 tensorflow版本:1.15.0 之前我们就已 ...

  4. Hi3559AV100 NNIE开发(3)RuyiStudio软件 .wk文件生成过程-mobilefacenet.cfg的参数配置

    之后随笔将更多笔墨着重于NNIE开发系列,下文是关于Hi3559AV100 NNIE开发(3)RuyiStudio软件 .wk文件生成过程-mobilefacenet.cfg的参数配置,目前项目需要对 ...

  5. 转:浅谈UNIX下Apache的MPM及httpd.conf配置文件中相关参数配置

    为什么要并发处理 以Apache为代表的web服务器中,如果不支持并发,则在一个客户端连接的时候,如果该客户端的任务没有处理完,其他连接的客户端将会一直处于等待状态,这事不可想象的,好像没有为什么要不 ...

  6. Spark on Yarn:任务提交参数配置

    当在YARN上运行Spark作业,每个Spark executor作为一个YARN容器运行.Spark可以使得多个Tasks在同一个容器里面运行. 以下参数配置为例子: spark-submit -- ...

  7. Production环境中iptables常用参数配置

    production环境中iptables常用参数配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 我相信在实际生产环境中有很多运维的兄弟跟我一样,很少用到iptables的这个 ...

  8. Unity3D安卓打包参数配置与兼容性的关系分析

    前言 在使用Unity3D工程导出安卓安装包的时候,往往会遇到兼容性的问题,针对某些机型,要么无法打开游戏,要么会出现卡机的现象.面对这种情况,我们可以调节相关的参数来提高兼容性. 为了了解在打包时候 ...

  9. 教你如何利用分布式的思想处理集群的参数配置信息——spring的configurer妙用

    引言 最近LZ的技术博文数量直线下降,实在是非常抱歉,之前LZ曾信誓旦旦的说一定要把<深入理解计算机系统>写完,现在看来,LZ似乎是在打自己脸了.尽管LZ内心一直没放弃,但从现状来看,需要 ...

随机推荐

  1. UIView 的旋转和缩放

    原文地址:http://www.cnblogs.com/gaoxiao228/archive/2012/05/04/2483577.html label.transform = CGAffineTra ...

  2. h.264 x.264

    这是两个不同类型的东西. x264是视频编码器,H.264是视频编码格式. x264编出来的东西就是h.264的.举个例子来说,x264就好比画图或者photoshop,h.264就好比jpg,bmp ...

  3. java基础之static(静态)

    静态的属性.方法等属于类而不是对象. 静态的方法能够由类直接调用,不须要将类实例化. 本篇主要说明:1.态的代码.成员变量要比构造方法先运行. 2. 子类的构造方法会默认去调用父类的不带參数的构造方法 ...

  4. 权力的游戏第七季/全集Game of Thrones迅雷下载

    艾美及金球奖获奖HBO原创剧集<权力的游戏>第七季将于2016年夏天晚些时候开拍.新的一季共有七集,主要拍摄地为北爱尔兰,部分镜头也将在西班牙和冰岛取景.上映时间预计将略有推迟,至2017 ...

  5. 拦截器通过Spring获取工厂类,注入bean对象

    // 这里需要注意一点,我们在拦截器内无法通过SpringBean的方式注入LoggerJPA,我只能通过另外一种形式. /** * 根据传入的类型获取spring管理的对应dao * @param ...

  6. Chapter 4 -- Throwables

    TODO: rewrite with more examples Guava's Throwables utility can frequently simplify dealing with exc ...

  7. 以双斜杠//开头的URL的含义

    在HTML网页中,有时会发现类似于//www.studyofnet.com/news/1341.html这样的代码,那么,这种以双斜杠//开头的URL的含义是什么呢? 在WEB网页中,有时会发现类似下 ...

  8. C/C++ 关于 for循环 的第二个表达式右侧非常量的时候

    废话不多说,直接看代码: #include<stdio.h> int main(){ ; ;z<zmax;z++){ printf("i=%d z=%d\n",i ...

  9. .Net-using-Class:MemoryCache 类

    ylbtech-.Net-using-Class:MemoryCache 类 初始化 System.Runtime.Caching.MemoryCache 类的新实例. 1. 程序集 System.R ...

  10. Sharepoint2013 Report Service初探

    首先需要建立相应的report报表 如图: 这里的sql如下: SELECT PC.Name AS Category, PS.Name AS Subcategory, DATEPART(yy, SOH ...