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

来源:互联网 发布:浙江师范大学行知学院 编辑:程序博客网 时间:2024/05/01 19:44

和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. }  
0 0
原创粉丝点击