mirror of
https://github.com/THU-MIG/yolov10.git
synced 2025-05-23 21:44:22 +08:00
Fix RTDETR generate anchor grid out of boundary (#7247)
This commit is contained in:
parent
865616da9f
commit
9043272f78
@ -303,7 +303,7 @@ class RTDETRDecoder(nn.Module):
|
|||||||
grid_y, grid_x = torch.meshgrid(sy, sx, indexing='ij') if TORCH_1_10 else torch.meshgrid(sy, sx)
|
grid_y, grid_x = torch.meshgrid(sy, sx, indexing='ij') if TORCH_1_10 else torch.meshgrid(sy, sx)
|
||||||
grid_xy = torch.stack([grid_x, grid_y], -1) # (h, w, 2)
|
grid_xy = torch.stack([grid_x, grid_y], -1) # (h, w, 2)
|
||||||
|
|
||||||
valid_WH = torch.tensor([h, w], dtype=dtype, device=device)
|
valid_WH = torch.tensor([w, h], dtype=dtype, device=device)
|
||||||
grid_xy = (grid_xy.unsqueeze(0) + 0.5) / valid_WH # (1, h, w, 2)
|
grid_xy = (grid_xy.unsqueeze(0) + 0.5) / valid_WH # (1, h, w, 2)
|
||||||
wh = torch.ones_like(grid_xy, dtype=dtype, device=device) * grid_size * (2.0 ** i)
|
wh = torch.ones_like(grid_xy, dtype=dtype, device=device) * grid_size * (2.0 ** i)
|
||||||
anchors.append(torch.cat([grid_xy, wh], -1).view(-1, h * w, 4)) # (1, h*w, 4)
|
anchors.append(torch.cat([grid_xy, wh], -1).view(-1, h * w, 4)) # (1, h*w, 4)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user