From 9b771a3e7112f864cb9c877733eca9240e8fb4a5 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 21 Mar 2022 09:33:39 +0100 Subject: [PATCH] Revert "Update detect.py non-inplace with `y.tensor_split()` (#7062)" (#7074) This reverts commit d5e363f29d7619f2a186678eb6d61672f49b11f1. --- models/yolo.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/models/yolo.py b/models/yolo.py index 09215101e8a0..2f4bbe0f71d1 100644 --- a/models/yolo.py +++ b/models/yolo.py @@ -62,10 +62,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, wh, conf = y.tensor_split((2, 4), 4) - xy = (xy * 2 - 0.5 + self.grid[i]) * self.stride[i] # xy - wh = (wh * 2) ** 2 * self.anchor_grid[i] # wh - y = torch.cat((xy, wh, conf), 4) + xy = (y[..., 0:2] * 2 - 0.5 + self.grid[i]) * self.stride[i] # xy + wh = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i] # wh + y = torch.cat((xy, wh, y[..., 4:]), -1) z.append(y.view(bs, -1, self.no)) return x if self.training else (torch.cat(z, 1), x)