`ultralytics 8.2.28` improved NMS speeds (#13315)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
pull/13341/head v8.2.28
Glenn Jocher 6 months ago committed by GitHub
parent 90f2a4226c
commit 5df2d167a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      ultralytics/__init__.py
  2. 2
      ultralytics/nn/autobackend.py
  3. 12
      ultralytics/utils/ops.py

@ -1,6 +1,6 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license # Ultralytics YOLO 🚀, AGPL-3.0 license
__version__ = "8.2.27" __version__ = "8.2.28"
import os import os

@ -184,7 +184,7 @@ class AutoBackend(nn.Module):
LOGGER.info(f"Loading {w} for ONNX Runtime inference...") LOGGER.info(f"Loading {w} for ONNX Runtime inference...")
check_requirements(("onnx", "onnxruntime-gpu" if cuda else "onnxruntime")) check_requirements(("onnx", "onnxruntime-gpu" if cuda else "onnxruntime"))
if IS_RASPBERRYPI or IS_JETSON: if IS_RASPBERRYPI or IS_JETSON:
# Fix error: module 'numpy.linalg._umath_linalg' has no attribute '_ilp64' when exporting to Tensorflow SavedModel on RPi and Jetson # Fix 'numpy.linalg._umath_linalg' has no attribute '_ilp64' for TF SavedModel on RPi and Jetson
check_requirements("numpy==1.23.5") check_requirements("numpy==1.23.5")
import onnxruntime import onnxruntime

@ -402,7 +402,7 @@ def xyxy2xywh(x):
def xywh2xyxy(x): def xywh2xyxy(x):
""" """
Convert bounding box coordinates from (x, y, width, height) format to (x1, y1, x2, y2) format where (x1, y1) is the Convert bounding box coordinates from (x, y, width, height) format to (x1, y1, x2, y2) format where (x1, y1) is the
top-left corner and (x2, y2) is the bottom-right corner. top-left corner and (x2, y2) is the bottom-right corner. Note: ops per 2 channels faster than per channel.
Args: Args:
x (np.ndarray | torch.Tensor): The input bounding box coordinates in (x, y, width, height) format. x (np.ndarray | torch.Tensor): The input bounding box coordinates in (x, y, width, height) format.
@ -412,12 +412,10 @@ def xywh2xyxy(x):
""" """
assert x.shape[-1] == 4, f"input shape last dimension expected 4 but input shape is {x.shape}" 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) # faster than clone/copy
dw = x[..., 2] / 2 # half-width xy = x[..., :2] # centers
dh = x[..., 3] / 2 # half-height wh = x[..., 2:] / 2 # half width-height
y[..., 0] = x[..., 0] - dw # top left x y[..., :2] = xy - wh # top left xy
y[..., 1] = x[..., 1] - dh # top left y y[..., 2:] = xy + wh # bottom right xy
y[..., 2] = x[..., 0] + dw # bottom right x
y[..., 3] = x[..., 1] + dh # bottom right y
return y return y

Loading…
Cancel
Save