Unverified 提交 7cef03dd authored 作者: Glenn Jocher's avatar Glenn Jocher 提交者: GitHub

Fix torch `long` to `float` tensor on HUB macOS (#8067)

上级 a80dd66e
...@@ -195,8 +195,8 @@ class ComputeLoss: ...@@ -195,8 +195,8 @@ class ComputeLoss:
device=self.device).float() * g # offsets device=self.device).float() * g # offsets
for i in range(self.nl): for i in range(self.nl):
anchors = self.anchors[i] anchors, shape = self.anchors[i], p[i].shape
gain[2:6] = torch.tensor(p[i].shape)[[3, 2, 3, 2]] # xyxy gain gain[2:6] = torch.tensor(shape)[[3, 2, 3, 2]] # xyxy gain
# Match targets to anchors # Match targets to anchors
t = targets * gain # shape(3,n,7) t = targets * gain # shape(3,n,7)
...@@ -226,7 +226,7 @@ class ComputeLoss: ...@@ -226,7 +226,7 @@ class ComputeLoss:
gi, gj = gij.T # grid indices gi, gj = gij.T # grid indices
# Append # 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 tbox.append(torch.cat((gxy - gij, gwh), 1)) # box
anch.append(anchors[a]) # anchors anch.append(anchors[a]) # anchors
tcls.append(c) # class tcls.append(c) # class
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论