From bb7c7ae811eb7b657484d3f54603d418f75a4b6d Mon Sep 17 00:00:00 2001 From: Muhammad Rizwan Munawar Date: Fri, 6 Dec 2024 00:26:28 +0500 Subject: [PATCH] Fix `np.empty_like` function input type (#18049) --- ultralytics/utils/ops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ultralytics/utils/ops.py b/ultralytics/utils/ops.py index ac53546e..c6ebaf65 100644 --- a/ultralytics/utils/ops.py +++ b/ultralytics/utils/ops.py @@ -469,7 +469,7 @@ def xyxy2xywhn(x, w=640, h=640, clip=False, eps=0.0): if clip: x = clip_boxes(x, (h - eps, w - eps)) assert x.shape[-1] == 4, f"input shape last dimension expected 4 but input shape is {x.shape}" - y = torch.empty_like(x) if isinstance(x, torch.Tensor) else np.empty_like(x) # faster than clone/copy + y = torch.empty_like(x) if isinstance(x, torch.Tensor) else np.empty_like(x, dtype=float) # faster than clone/copy y[..., 0] = ((x[..., 0] + x[..., 2]) / 2) / w # x center y[..., 1] = ((x[..., 1] + x[..., 3]) / 2) / h # y center y[..., 2] = (x[..., 2] - x[..., 0]) / w # width