Faster rcnn--改变anchor的size
来源:互联网 发布:2016中国象棋软件排名 编辑:程序博客网 时间:2024/06/08 13:48
Faster rcnn–改变anchor的size
- 代码用的是py-faster-rcnn:https://github.com/rbgirshick/py-faster-rcnn
- 训练时用的模型和方法:models\pascal_voc\VGG_CNN_M_1024\faster_rcnn_end2end
修改generate_anchors.py
#ratios中加了一种比例1.5,所以anchor的数量为4*3=12def generate_anchors(base_size=16, ratios=[0.5, 1, 1.5, 2], scales=2**np.arange(3, 6)): """ Generate anchor (reference) windows by enumerating aspect ratios X scales wrt a reference (0, 0, 15, 15) window. """ base_anchor = np.array([1, 1, base_size, base_size]) - 1 ratio_anchors = _ratio_enum(base_anchor, ratios) anchors = np.vstack([_scale_enum(ratio_anchors[i, :], scales) for i in xrange(ratio_anchors.shape[0])]) return anchors
修改train.prototxt
layer { name: "rpn_cls_score" type: "Convolution" bottom: "rpn/output" top: "rpn_cls_score" param { lr_mult: 1.0 } param { lr_mult: 2.0 } convolution_param { num_output: 24 # 2(bg/fg) * 12(anchors) kernel_size: 1 pad: 0 stride: 1 weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 0 } }
layer { name: "rpn_bbox_pred" type: "Convolution" bottom: "rpn/output" top: "rpn_bbox_pred" param { lr_mult: 1.0 } param { lr_mult: 2.0 } convolution_param { num_output: 48 # 4 * 12(anchors) kernel_size: 1 pad: 0 stride: 1 weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 0 } }}
layer { name: 'rpn_cls_prob_reshape' type: 'Reshape' bottom: 'rpn_cls_prob' top: 'rpn_cls_prob_reshape' reshape_param { shape { dim: 0 dim: 24 dim: -1 dim: 0 } }}
修改test.prototxt
同train.prototxt
上述步骤只针对改ratios,如果你想改scales,还要进行以下修改
修改generate_anchors.py
#anchor的数量为4*5=20def generate_anchors(base_size=16, ratios=[0.5, 1, 1.5, 2], scales=2**np.arange(1, 6)): """ Generate anchor (reference) windows by enumerating aspect ratios X scales wrt a reference (0, 0, 15, 15) window. """ base_anchor = np.array([1, 1, base_size, base_size]) - 1 ratio_anchors = _ratio_enum(base_anchor, ratios) anchors = np.vstack([_scale_enum(ratio_anchors[i, :], scales) for i in xrange(ratio_anchors.shape[0])]) return anchors
修改anchor_target_layer.py
def setup(self, bottom, top): layer_params = yaml.load(self.param_str) anchor_scales = layer_params.get('scales', (2, 4, 8, 16, 32)) self._anchors = generate_anchors(scales=np.array(anchor_scales)) self._num_anchors = self._anchors.shape[0] self._feat_stride = layer_params['feat_stride']
修改proposal_layer.py
def setup(self, bottom, top): # parse the layer parameter string, which must be valid YAML layer_params = yaml.load(self.param_str) self._feat_stride = layer_params['feat_stride'] anchor_scales = layer_params.get('scales', (2, 4, 8, 16, 32)) self._anchors = generate_anchors(scales=np.array(anchor_scales)) self._num_anchors = self._anchors.shape[0]
如果报错,删除faster_rcnn_version\fasterRcnn_final_v1_3\data\cache下.pkl文件
阅读全文
0 0
- Faster rcnn--改变anchor的size
- 3 faster rcnn的anchor产生问题
- faster rcnn中rpn的anchor
- Faster RCNN:RPN,anchor,sliding windows
- caffe下py-Faster RCNN end2end模式修改anchor的scale大小
- faster rcnn RPN之anchor(generate_anchors)源码解析
- Faster RCNN 源码解析(3.2) -- Anchor 生成(generate_anchors.py)
- 【修改anchor】目标检测框架py-faster-rcnn修改anchor_box
- faster-rcnn的记录
- faster rcnn的测试
- 从RCNN到Faster RCNN 的发展
- Faster RCNN 的py-faster-rcnn详细配置安装过程
- faster rcnn 的重新训练
- faster-rcnn遇到的问题
- Faster RCNN的理解点
- faster RCNN 的细节理解
- Faster-RCNN遇到的问题
- Faster RCNN训练出现问题:generated_database_->Add(encoded_file_descriptor, size)
- jQuery向后台传入json格式数据的方法
- 我使用过的Linux命令之unrar
- 学会4种备份MySQL数据库(基本备份方面没问题了)
- 异常(try……catch……finally、throws和throw的区别、自定义异常)
- 习题 5.3 输入两个正整数m和n,求其最大公约数和最小公倍数。
- Faster rcnn--改变anchor的size
- 解决Spring的声明式事务中的自定义异常不回滚问题
- Java中数组的使用
- CNN的训练图像与测试图像不一致的多尺度问题
- 名字隐藏与重载
- WebRTC学习之ICE深入理解
- 使用python获取email的subject中带有指定字符串的邮件
- leetcode--Balanced Binary Tree
- 深入理解jquery新的绑定事件机制on方法的使用(推荐)