Faster-RCNN+VGG用自己的数据集训练模型

和ZF差不多,基本一样。不同的地方主要是网络模型的修改和训练结束后的修改。

1-6参考Faster-RCNN+ZF用自己的数据集训练模型

7.网络的修改

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

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. input: "bbox_targets"  
  2. input_dim: 1  # to be changed on-the-fly to match num ROIs  
  3. input_dim: 20 #  4*(类别数+1) (=21)   
  4. input_dim: 1  
  5. input_dim: 1  

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. input: "bbox_loss_weights"  
  2. input_dim: 1  # to be changed on-the-fly to match num ROIs  
  3. input_dim: 20 # 4*(类别数+1)  
  4. input_dim: 1  
  5. input_dim: 1  

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  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: 5 #类别数+1  
  14.         weight_filler {  
  15.             type: "gaussian"  
  16.             std: 0.01  
  17.         }  
  18.         bias_filler {  
  19.             type: "constant"  
  20.             value: 0  
  21.         }  
  22.     }  
  23. }  

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  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: 20 #4*(类别数+1)  
  14.         weight_filler {  
  15.             type: "gaussian"  
  16.             std: 0.001  
  17.         }  
  18.         bias_filler {  
  19.             type: "constant"  
  20.             value: 0  
  21.         }  
  22.     }  
  23. }  

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

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  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: 5 #类别数+1  
  14.         weight_filler {  
  15.             type: "gaussian"  
  16.             std: 0.01  
  17.         }  
  18.         bias_filler {  
  19.             type: "constant"  
  20.             value: 0  
  21.         }  
  22.     }  
  23. }  

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  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: 20 #4*(类别数+1)  
  14.         weight_filler {  
  15.             type: "gaussian"  
  16.             std: 0.001  
  17.         }  
  18.         bias_filler {  
  19.             type: "constant"  
  20.             value: 0  
  21.         }  
  22.     }  
  23. }  

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

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. input: "bbox_targets"  
  2. input_dim: 1  # to be changed on-the-fly to match num ROIs  
  3. input_dim: 20 # 4*(类别数+1)   
  4. input_dim: 1  
  5. input_dim: 1  
[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. input: "bbox_loss_weights"  
  2. input_dim: 1  # to be changed on-the-fly to match num ROIs  
  3. input_dim: 20 # 4* (类别数+1)   
  4. input_dim: 1  
  5. input_dim: 1  

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  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: 5 #类别数+1  
  14.         weight_filler {  
  15.             type: "gaussian"  
  16.             std: 0.01  
  17.         }  
  18.         bias_filler {  
  19.             type: "constant"  
  20.             value: 0  
  21.         }  
  22.     }  
  23. }  

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  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: 20 #4*(类别数+1)  
  14.         weight_filler {  
  15.             type: "gaussian"  
  16.             std: 0.001  
  17.         }  
  18.         bias_filler {  
  19.             type: "constant"  
  20.             value: 0  
  21.         }  
  22.     }  
  23. }  

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

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  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:5  #类别数+1  
  14.         weight_filler {  
  15.             type: "gaussian"  
  16.             std: 0.01  
  17.         }  
  18.         bias_filler {  
  19.             type: "constant"  
  20.             value: 0  
  21.         }  
  22.     }  
  23. }  

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  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: 20 #4*(类别数+1)  
  14.         weight_filler {  
  15.             type: "gaussian"  
  16.             std: 0.001  
  17.         }  
  18.         bias_filler {  
  19.             type: "constant"  
  20.             value: 0  
  21.         }  
  22.     }  
  23. }  


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

8.开始训练

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. experiments\script_faster_rcnn_VOC2007_VGG16.m  

9.训练完后

将relu5(包括relu5)前的层删除,并将roi_pool5的bottom改为data和rois。并且前面的input_dim:分别改为1,512,50,50,具体如下:
[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. input: "data"  
  2. input_dim: 1  
  3. input_dim: 512  
  4. input_dim: 50  
  5. input_dim: 50  

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. layer {  
  2.     bottom: "data"  
  3.     bottom: "rois"  
  4.     top: "pool5"  
  5.     name: "roi_pool5"  
  6.     type: "ROIPooling"  
  7.     roi_pooling_param {  
  8.         pooled_w: 7  
  9.         pooled_h: 7  
  10.         spatial_scale: 0.0625  # (1/16)  
  11.     }  
  12. }  
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值