和ZF差不多,基本一样。不同的地方主要是网络模型的修改和训练结束后的修改。
1-6参考Faster-RCNN+ZF用自己的数据集训练模型
7.网络的修改
(1)models\fast_rcnn_prototxts\vgg_16layers_fc6\train_val.prototxt
- input: "bbox_targets"
- input_dim: 1 # to be changed on-the-fly to match num ROIs
- input_dim: 20 # 4*(类别数+1) (=21)
- 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: 20 # 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: 5 #类别数+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: 20 #4*(类别数+1)
- weight_filler {
- type: "gaussian"
- std: 0.001
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
- }
(2)models\fast_rcnn_prototxts\vgg_16layers_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: 5 #类别数+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: 20 #4*(类别数+1)
- weight_filler {
- type: "gaussian"
- std: 0.001
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
- }
(3)models\fast_rcnn_prototxts\vgg_16layers_conv3_1\train_val.prototxt
- input: "bbox_targets"
- input_dim: 1 # to be changed on-the-fly to match num ROIs
- input_dim: 20 # 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: 20 # 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: 5 #类别数+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: 20 #4*(类别数+1)
- weight_filler {
- type: "gaussian"
- std: 0.001
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
- }
(4)models\fast_rcnn_prototxts\vgg_16layers_conv3_1\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:5 #类别数+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: 20 #4*(类别数+1)
- weight_filler {
- type: "gaussian"
- std: 0.001
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
- }
!!!为防止与之前的模型搞混,训练前把output文件夹删除(或改个其他名),还要把imdb\cache中的文件删除(如果有的话)
8.开始训练
将relu5(包括relu5)前的层删除,并将roi_pool5的bottom改为data和rois。并且前面的input_dim:分别改为1,512,50,50,具体如下:
- input: "data"
- input_dim: 1
- input_dim: 512
- input_dim: 50
- input_dim: 50
- layer {
- bottom: "data"
- bottom: "rois"
- top: "pool5"
- name: "roi_pool5"
- type: "ROIPooling"
- roi_pooling_param {
- pooled_w: 7
- pooled_h: 7
- spatial_scale: 0.0625 # (1/16)
- }
- }
本文介绍如何基于Faster R-CNN框架和VGG16网络,使用自定义数据集进行目标检测模型的训练及调整。主要内容包括网络结构调整、参数设置等关键步骤。
9万+

被折叠的 条评论
为什么被折叠?



