keras Mask Rcnn代码走读(二) - anchors的产生

一,生成 anchors需要的参数
self.config.BACKBONE_STRIDES = [4, 8, 16, 32, 64]

特征层的下采样倍数,中心点计算使用

self.config.RPN_ANCHOR_RATIOS = [0.5, 1, 2]

特征层锚框生成参数

self.config.RPN_ANCHOR_SCALES = [32, 64, 128, 256, 512]

特征层锚框感受野

image shape(1024,1024,3)

二, anchors特点
1.中心点的个数等于特征层像素数
2.框体生成是围绕中心点的
3.最终的框体坐标需要归一化,都是对于输入图片的相对大小

三,锚框生成入口函数位于model.py中的get_anchor函数,需要参数image_shape,保证含有[h, w]即可,也可以包含[h, w, c],

def get_anchors(self, image_shape):
    """Returns anchor pyramid for the given image size."""
    # [N, (height, width)]
    backbone_shapes = compute_backbone_shapes(self.config, image_shape)
    # Cache anchors and reuse if image shape is the same
    if not hasattr(self, "_anchor_cache"):
        self._anchor_cache = {
   }
    if not tuple(image_shape) in self._anchor_cache:
        # Generate Anchors: [anchor_count, (y1, x1, y2, x2)]
        a = utils.generate_pyramid_anchors(
            self.config.RPN_ANCHOR_SCALES,  # (32, 64, 128, 256, 512)
            self.config.RPN_ANCHOR_RATIOS,  # [0.5, 1, 2]
            backbone_shapes,                # with shape [N, (height, width)]
            self.config.BACKBONE_STRIDES,   # [4, 8, 16, 32, 64]
            self.config.RPN_ANCHOR_STRIDE)  # 1
        # Keep a copy of the latest anchors in pixel coordinates because
        # it's used in inspect_model notebooks.
        # TODO: Remove this after the notebook are refactored to not use it
        self.anchors = a
        # Normalize coordinates
        self._anchor_cache[tuple(image_shape)] = utils.</
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值