在前一篇随笔中,数据制作成了VOC2007格式,可以用于Faster-RCNN的训练。

1.针对数据的修改

修改datasets\VOCdevkit2007\VOCcode\VOCinit.m,我只做了两类

VOCopts.classes={...'dog''flower'};

修改function\fast_rcnn\fast_rcnn_train.m,val_iters不能大于val数据量(我的只有几十个)。

ip.addParamValue('val_iters',       20,            @isscalar); 

修改function\rpn\proposal_train.m,与上一致。

ip.addParamValue('val_iters',           20,                @isscalar);

修改models\fast_rcnn_prototxts中两个文件夹里面的train_val.prototxt和test.prototxt,以K代表类别数做相应的修改,(共4个文件修改12处)。

input: "bbox_targets"
input_dim: 1  # to be changed on-the-fly to match num ROIs
input_dim: 12 # 4 * (K+1) (=21) classes
input_dim: 1
input_dim: 1input: "bbox_loss_weights"
input_dim: 1  # to be changed on-the-fly to match num ROIs
input_dim: 12 # 4 * (K+1) (=21) classes
input_dim: 1
input_dim: 1

type: "InnerProduct"inner_product_param {num_output: 3  #K+1
        weight_filler {type: "gaussian"std: 0.01}bias_filler {type: "constant"value: 0}}

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: 3  # K+1
        weight_filler {type: "gaussian"std: 0.01}bias_filler {type: "constant"value: 0}}
}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: 12  # 4 * (K+1)
        weight_filler {type: "gaussian"std: 0.001}bias_filler {type: "constant"value: 0}}
}

修改experiments\+Model\ZF_for_Faster_RCNN_VOC2007.m的三个为solver_30k40k.prototxt,默认60k80k所需时间过长。

2.根据设备性能的修改

显卡GTX750,显存2G,尽管数据不多,在默认设置下出现了内存不够的错误。

修改functions\fast_rcnn\fast_rcnn_config.m,以%标注的为默认值。

%% training% whether use gpuip.addParamValue('use_gpu',         gpuDeviceCount > 0, ...            @islogical);% Image scales -- the short edge of input image                                                ip.addParamValue('scales',          60,            @ismatrix);  %600% Max pixel size of a scaled input imageip.addParamValue('max_size',        1000,           @isscalar);% Images per batchip.addParamValue('ims_per_batch',   2,              @isscalar);% Minibatch sizeip.addParamValue('batch_size',      32,            @isscalar);  %128% Fraction of minibatch that is foreground labeled (class > 0)ip.addParamValue('fg_fraction',     0.25,           @isscalar);% Overlap threshold for a ROI to be considered foreground (if >= fg_thresh)ip.addParamValue('fg_thresh',       0.5,            @isscalar);% Overlap threshold for a ROI to be considered background (class = 0 if% overlap in [bg_thresh_lo, bg_thresh_hi))ip.addParamValue('bg_thresh_hi',    0.5,            @isscalar);ip.addParamValue('bg_thresh_lo',    0.1,            @isscalar);% mean image, in RGB orderip.addParamValue('image_means',     128,            @ismatrix);% Use horizontally-flipped images during training?ip.addParamValue('use_flipped',     true,           @islogical);% Vaild training sample (IoU > bbox_thresh) for bounding box regresionip.addParamValue('bbox_thresh',     0.5,            @isscalar);% random seedip.addParamValue('rng_seed',        6,              @isscalar);%% testingip.addParamValue('test_scales',     60,            @isscalar);  %600ip.addParamValue('test_max_size',   1000,           @isscalar);ip.addParamValue('test_nms',        0.3,            @isscalar);ip.addParamValue('test_binary',     false,          @islogical);

3.开始训练

训练前删除或备份output,imdb\cache,运行experiments/script_faster_rcnn_VOC2007_ZF.m 开始训练。

在我的显卡上经过四个小时,训练完成。

下面是未删除output重新运行(很快)的结果。

***************
stage one proposal
***************
aver_boxes_num = 1090, select top 2000
aver_boxes_num = 1091, select top 2000***************
stage one fast rcnn
***************
!!! dog : 0.8969 0.9418
!!! flower : 0.9006 0.9458~~~~~~~~~~~~~~~~~~~~
Results:89.692090.060689.8763~~~~~~~~~~~~~~~~~~~~***************
stage two proposal
***************
aver_boxes_num = 1263, select top 2000
aver_boxes_num = 1271, select top 2000***************
stage two fast rcnn
******************************
final test
***************
aver_boxes_num = 233, select top 300
!!! dog : 0.8893 0.9449
!!! flower : 0.8990 0.9445~~~~~~~~~~~~~~~~~~~~
Results:88.930489.902589.4165~~~~~~~~~~~~~~~~~~~~
Cleared 0 solvers and 2 stand-alone nets
please modify detection_test.prototxt file for sharing conv layers with proposal model (delete layers until relu5)
>> 

4.测试

训练结束已有提示,要先修改detection_test.prototxt。

修改data为1*256*50*50,去掉roi_pool5之前的layer并将bottom改为data。

name: "Zeiler_conv5"input: "data"
input_dim: 1
input_dim: 256
input_dim: 50
input_dim: 50input: "rois"
input_dim: 1 # to be changed on-the-fly to num ROIs
input_dim: 5 # [batch ind, x1, y1, x2, y2] zero-based indexing
input_dim: 1
input_dim: 1layer {bottom: "data"bottom: "rois"top: "pool5"name: "roi_pool5"type: "ROIPooling"roi_pooling_param {pooled_w: 6pooled_h: 6spatial_scale: 0.0625  # (1/16)
    }
}

在experiments\script_faster_rcnn_demo.m中将路径更改成本地相应路径,根据测试结果可以修改thres值。

model_dir                   = fullfile(pwd, 'output', 'faster_rcnn_final', 'faster_rcnn_VOC2007_ZF'); %% ZF_test

im_names = {'000001.jpg','000002.jpg','000034.jpg','000212.jpg','000213.jpg', '001150.jpg'};

thres = 0.3;  %0.6

检测速度很快,不过此次我的数据检测效果很不好,可能由于数据太少、画框不认真或某些没有意识到的参数错误-_-!。

转载于:https://www.cnblogs.com/qw12/p/6188769.html

Faster-RCNN 训练自己的数据相关推荐

  1. Faster RCNN 训练中的一些问题及解决办法

    今天使用Faster RCNN训练自己的数据的时候,出现了一些因为boost或者是numpy版本不兼容导致的问题,经过各种查资料和求助大神,总算是顺利把网络跑起来了.下面内容都是今天亲测出现的问题并与 ...

  2. Faster rcnn 训练coco2017数据报错 RuntimeError: CUDA error: device-side assert triggered

    Faster rcnn 训练coco2017数据报错 RuntimeError: CUDA error: device-side assert triggered 使用faster rcnn训练自己的 ...

  3. Faster RCNN 训练自己的检测模型

    Faster RCNN 训练自己的检测模型 一.准备自己的训练数据 根据pascal VOC 2007的训练数据集基本架构,第一步,当然是要准备自己的训练图片集,本文直接将自己的准备的图片集(.jpg ...

  4. 目标检测simple Faster R-CNN训练自己的数据集

    一.复现 刚开始接触目标检测,自己动手复现的第一个开源项目是github上chenyuntc的simple faster rcnn.历经千辛万苦最后貌似因为服务器显卡内存不够,在训练时一直出现一个错误 ...

  5. faster r-cnn训练、测试、检测(含批量检测图片)

    faster r-cnn(tensorflow版本)训练VOC数据集.测试.检测指南 使用的faster r-cnn代码github地址 https://github.com/endernewton/ ...

  6. Faster RCNN训练自己数据集报错记录及解决

    Faster R-CNN源码网址:https://github.com/dBeker/Faster-RCNN-TensorFlow-Python3.5点击打开链接 环境:python3.6 tenso ...

  7. Faster RCNN训练FLIR红外线数据集

    1. Fater RCNN检测网络下载 网络学习视频 [源码地址]https://github.com/bubbliiiing/faster-rcnn-pytorch 2. FLIR 数据集准备 数据 ...

  8. Mask Scoring RCNN训练自己的数据

    一. 代码准备 基于pytorch. mask scoring rcnn 代码参考:[github] mask rcnn benchmark [github] 二. 环境安装 1. 基于conda创建 ...

  9. faster rcnn 训练自己的数据集---踩坑记录!!!

    1.下载代码: git clone https://github.com/jwyang/faster-rcnn.pytorch.git 也可以暴力下载<--直接download压缩包--> ...

  10. faster rcnn训练过程讲解

    http://blog.csdn.net/u014696921/article/details/60321425

最新文章

  1. 微信小程序与H5相互跳转和传递数据
  2. DPM2010恢复exchange2010单个用户邮箱邮件
  3. 12家国内外之名公司多场面试,微软到谷歌.让我们通过学习达到100%面试率与100%通过率...
  4. 网页导出pdf不完整_网站中的页面如何转成PDF文档?
  5. 这些面试题你需要知道
  6. 如何创建线程?如何创建扩展Thread类?
  7. nginx 禁止访问配置,指定URL地址指定IP允许访问
  8. allure 测试报告本地打开_自动化测试报告太丑?信息实用的Allure Report测试报告拯救你...
  9. java 16进制_JAVA 十六进制与字符串的转换
  10. android开发 问卷调查案例_android 实现调查问卷-单选-多选
  11. Ubuntu18网络配置
  12. python的拼音_Python之拼音拆分
  13. 六步换向两两导通和三三导通的区别2
  14. 运算放大器 之 概述
  15. 小小总结之渗透测试面试题以及答案
  16. 使用M25或M26进行FTP文件下载的程序设计与实现
  17. 修改war包中数据库配置信息
  18. Android Tips - 填坑手册
  19. 毕业设计-基于深度学习的图像质量评价
  20. 渲染大面积草地时,如何降低消耗?

热门文章

  1. 大数据与Hadoop的区别
  2. 大数据杀熟,是真的吗?
  3. 成年男女间存在真正的友谊吗?
  4. 大家为什么去国企后都不想跳槽了?
  5. V商变现的逻辑和自媒体变现的逻辑
  6. 2020没赚到,你真的该好好想想了
  7. 创始团队的执行力很重要
  8. C语言学习篇(32)——为什么C语言不能函数重载
  9. ubuntu 安装docker
  10. sql azure 语法_Azure SQL Server自动故障转移组