diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index 0bb5c41e..5e1364da 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -__version__ = "8.2.14" +__version__ = "8.2.15" from ultralytics.data.explorer.explorer import Explorer from ultralytics.models import RTDETR, SAM, YOLO, YOLOWorld diff --git a/ultralytics/utils/torch_utils.py b/ultralytics/utils/torch_utils.py index f859cd5f..919fee07 100644 --- a/ultralytics/utils/torch_utils.py +++ b/ultralytics/utils/torch_utils.py @@ -399,8 +399,13 @@ def copy_attr(a, b, include=(), exclude=()): def get_latest_opset(): - """Return second-most (for maturity) recently supported ONNX opset by this version of torch.""" - return max(int(k[14:]) for k in vars(torch.onnx) if "symbolic_opset" in k) - 1 # opset + """Return the second-most recent ONNX opset version supported by this version of PyTorch, adjusted for maturity.""" + if TORCH_1_13: + # If the PyTorch>=1.13, dynamically compute the latest opset minus one using 'symbolic_opset' + return max(int(k[14:]) for k in vars(torch.onnx) if "symbolic_opset" in k) - 1 + # Otherwise for PyTorch<=1.12 return the corresponding predefined opset + version = torch.onnx.producer_version.rsplit(".", 1)[0] # i.e. '2.3' + return {"1.12": 15, "1.11": 14, "1.10": 13, "1.9": 12, "1.8": 12}.get(version, 12) def intersect_dicts(da, db, exclude=()):