seglink代码之 generate_anchors_one layer

'''
特别关注np.mgrid函数,例如 x, y = np.mgrid[0:4, 0:4]
x =
    0, 1, 2, 3
    0, 1, 2, 3
    0, 1, 2, 3
    0, 1, 2, 3

y =
    0, 0, 0, 0
    1, 1, 1, 1
    2, 2, 2, 2
    3, 3, 3, 3
利用这个函数的性质就能很方便的计算anchor_box的坐标值
此外,anchor_scale不是单纯的图像比,还是有一个尺度系数,在此设为1.5


'''
def _generate_anchors_one_layer(h_I, w_I, h_l, w_l):
    """
    generate anchors on on layer
    return a ndarray with shape (h_l, w_l, 4), and the last dimmension in the order:[cx, cy, w, h]
    """
    y, x = np.mgrid[0: h_l, 0:w_l]
    cy = (y + config.anchor_offset) / h_l * h_I
    cx = (x + config.anchor_offset) / w_l * w_I

    anchor_scale = _get_scale(w_I, w_l)
    anchor_w = np.ones_like(cx) * anchor_scale
    anchor_h = np.ones_like(cx) * anchor_scale # cx.shape == cy.shape

    anchors = np.asarray([cx, cy, anchor_w, anchor_h])
    anchors = np.transpose(anchors, (1, 2, 0))

    return anchors
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值