Fix np.empty_like function input type (#18049)
This commit is contained in:
parent
1618c69d13
commit
bb7c7ae811
1 changed files with 1 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue