Skip to content

Commit

Permalink
Refactor out-of-place Detect() for reduced ops (#7257)
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher committed Apr 3, 2022
1 parent ffcbd8c commit 4f839b7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions models/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def forward(self, x):
y[..., 0:2] = (y[..., 0:2] * 2 - 0.5 + self.grid[i]) * self.stride[i] # xy
y[..., 2:4] = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i] # wh
else: # for YOLOv5 on AWS Inferentia https://github.com/ultralytics/yolov5/pull/2953
xy = (y[..., 0:2] * 2 - 0.5 + self.grid[i]) * self.stride[i] # xy
xy = (y[..., 0:2] * 2 + (self.grid[i] - 0.5)) * self.stride[i] # xy
wh = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i] # wh
y = torch.cat((xy, wh, y[..., 4:]), -1)
y = torch.cat((xy, wh, y[..., 4:]), 4)
z.append(y.view(bs, -1, self.no))

return x if self.training else (torch.cat(z, 1), x)
Expand Down

0 comments on commit 4f839b7

Please sign in to comment.