计算feature map坐标方式

yolo-5

图中网格为13x13,即grid_size = 13。

将每个网格用(x,y)坐标表示。

grid = np.arrange(grid_size)
a, b = np.meshgrid(grid, grid)
#a,b 均为13x13矩阵
x_offset = torch.FloatTensor(a).view(-1, 1)
y_offset = torch.FloatTensor(b).view(-1, 1)
x_y_offset = torch.cat((x_offset, y_offset), 1).repeat(1, num_anchors).view(-1, 2).unsqueeze(0)

'''
( 0 ,.,.) = 
   0   0
   0   0
   0   0
   ⋮    
  12  12
  12  12
  12  12
[torch.FloatTensor of size 1x507x2]
'''

猜你喜欢

转载自blog.csdn.net/ncc1995/article/details/82684649