根据最后的feature map生成anchor的location

在物体检测算法中,通过backbone和卷积运算得到的feature map上的每个点(如YOLOv3的cell,FCOS的location)会预测边界框的偏移值。FCOS代码示例展示了如何生成grid坐标,每个cell对应一个坐标值。然而,对于10x10的map,实际网格坐标可能不应超过98x98。
摘要由CSDN通过智能技术生成

在物体检测中,经过backbone之后等等卷积操作,在最后的feature map将要根据feature map的每一个点(yolov3好像叫cell,FCOS叫location)做出预测,预测的框的偏移值(FCOS是l,r,t,b)都需要根据feature map的坐标映射到原图的坐标。
1、首先需要根据feature map的大小生成,网格的坐标,下面是FCOS的代码。

    def compute_location_per_level(self, height, width, stride, device):
        shift_x = torch.arange(
            0, width * stride, step=stride, dtype=torch.float32, device=device
        )
        shift_y = torch.arange(
            0, height * stride, step=stride, dtype=torch.float32, device=device
        )
        shift_y, shift_x = torch.meshgrid(shift_y, shift_x)
        shift_x = shift_x.reshape(-1)
        shift_y = shift_y.reshape(-1)
        location = torch.stack((shift_x, shift_y), 1) + stride // 2

        return location

输出的location就是每一个cell都有一个坐标值,如height, width大小的map,有height*width个cell,
用numpy写:

import n
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值