您的位置:首页 > 其它

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

2016-09-06 21:46 260 查看
和ZF差不多,基本一样。不同的地方主要是网络模型的修改和训练结束后的修改。

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


7.网络的修改


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

[plain] view
plain copy

 





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  

[plain] view
plain copy

 





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  

[plain] view
plain copy

 





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  

        }  

    }  

}  

[plain] view
plain copy

 





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

[plain] view
plain copy

 





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  

        }  

    }  

}  

[plain] view
plain copy

 





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

[plain] view
plain copy

 





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  

[plain] view
plain copy

 





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  

[plain] view
plain copy

 





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  

        }  

    }  

}  

[plain] view
plain copy

 





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

[plain] view
plain copy

 





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  

        }  

    }  

}  

[plain] view
plain copy

 





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.开始训练

[plain] view
plain copy

 





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

 





input: "data"  

input_dim: 1  

input_dim: 512  

input_dim: 50  

input_dim: 50  

[plain] view
plain copy

 





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)  

    }  

}  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: