From ffe6b2514f16f1e0a63faf1883c9b02401891f56 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Wed, 1 Jun 2022 17:34:46 +0200 Subject: [PATCH] Fix torch `long` to `float` tensor on HUB macOS (#8067) --- utils/loss.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/loss.py b/utils/loss.py index a1b0ff6c1244..9b9c3d9f8018 100644 --- a/utils/loss.py +++ b/utils/loss.py @@ -195,8 +195,8 @@ def build_targets(self, p, targets): device=self.device).float() * g # offsets for i in range(self.nl): - anchors = self.anchors[i] - gain[2:6] = torch.tensor(p[i].shape)[[3, 2, 3, 2]] # xyxy gain + anchors, shape = self.anchors[i], p[i].shape + gain[2:6] = torch.tensor(shape)[[3, 2, 3, 2]] # xyxy gain # Match targets to anchors t = targets * gain # shape(3,n,7) @@ -226,7 +226,7 @@ def build_targets(self, p, targets): gi, gj = gij.T # grid indices # Append - indices.append((b, a, gj.clamp_(0, gain[3] - 1), gi.clamp_(0, gain[2] - 1))) # image, anchor, grid indices + indices.append((b, a, gj.clamp_(0, shape[2] - 1), gi.clamp_(0, shape[3] - 1))) # image, anchor, grid tbox.append(torch.cat((gxy - gij, gwh), 1)) # box anch.append(anchors[a]) # anchors tcls.append(c) # class