From 3aba4203f9d489bdb2f42f02eecb233fcf25a755 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 21 Mar 2025 20:51:14 +0100 Subject: [PATCH] Require `coremltools>=8.0` (#19819) --- .github/workflows/ci.yml | 2 +- pyproject.toml | 4 ++-- tests/test_exports.py | 4 ++-- ultralytics/engine/exporter.py | 2 +- ultralytics/utils/benchmarks.py | 4 ++-- ultralytics/utils/checks.py | 1 + 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e17c10602..dd8ba97ae9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -317,7 +317,7 @@ jobs: - name: Install pip packages run: | # CoreML must be installed before export due to protobuf error from AutoInstall - pip install pytest "coremltools>=7.0; platform_system != 'Windows' and python_version <= '3.11'" + pip install pytest "coremltools>=8.0; platform_system != 'Windows' and python_version <= '3.12'" - name: Check environment run: | conda list diff --git a/pyproject.toml b/pyproject.toml index 224357eb9d..0ccc1f1b8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -95,8 +95,8 @@ dev = [ ] export = [ "onnx>=1.12.0", # ONNX export - "coremltools>=7.0; platform_system != 'Windows' and python_version <= '3.11'", # CoreML supported on macOS and Linux - "scikit-learn>=1.3.2; platform_system != 'Windows' and python_version <= '3.11'", # CoreML k-means quantization + "coremltools>=8.0; platform_system != 'Windows' and python_version <= '3.12'", # CoreML supported on macOS and Linux + "scikit-learn>=1.3.2; platform_system != 'Windows' and python_version <= '3.12'", # CoreML k-means quantization "openvino>=2024.0.0,!=2025.0.0", # OpenVINO export "tensorflow>=2.0.0", # TF bug https://github.com/ultralytics/ultralytics/issues/5161 "tensorflowjs>=4.0.0", # TF.js export, automatically installs tensorflow diff --git a/tests/test_exports.py b/tests/test_exports.py index 110cb6ca24..e985e647fc 100644 --- a/tests/test_exports.py +++ b/tests/test_exports.py @@ -114,7 +114,7 @@ def test_export_torchscript_matrix(task, dynamic, int8, half, batch, nms): @pytest.mark.slow @pytest.mark.skipif(not MACOS, reason="CoreML inference only supported on macOS") @pytest.mark.skipif(not TORCH_1_9, reason="CoreML>=7.2 not supported with PyTorch<=1.8") -@pytest.mark.skipif(checks.IS_PYTHON_3_12, reason="CoreML not supported in Python 3.12") +@pytest.mark.skipif(checks.IS_PYTHON_3_13, reason="CoreML not supported in Python 3.13") @pytest.mark.parametrize( "task, dynamic, int8, half, batch", [ # generate all combinations except for exclusion cases @@ -165,7 +165,7 @@ def test_export_tflite_matrix(task, dynamic, int8, half, batch, nms): @pytest.mark.skipif(not TORCH_1_9, reason="CoreML>=7.2 not supported with PyTorch<=1.8") @pytest.mark.skipif(WINDOWS, reason="CoreML not supported on Windows") # RuntimeError: BlobWriter not loaded @pytest.mark.skipif(LINUX and ARM64, reason="CoreML not supported on aarch64 Linux") -@pytest.mark.skipif(checks.IS_PYTHON_3_12, reason="CoreML not supported in Python 3.12") +@pytest.mark.skipif(checks.IS_PYTHON_3_13, reason="CoreML not supported in Python 3.13") def test_export_coreml(): """Test YOLO exports to CoreML format, optimized for macOS only.""" if MACOS: diff --git a/ultralytics/engine/exporter.py b/ultralytics/engine/exporter.py index 85c296dd66..472fb8e3dc 100644 --- a/ultralytics/engine/exporter.py +++ b/ultralytics/engine/exporter.py @@ -773,7 +773,7 @@ class Exporter: def export_coreml(self, prefix=colorstr("CoreML:")): """YOLO CoreML export.""" mlmodel = self.args.format.lower() == "mlmodel" # legacy *.mlmodel export format requested - check_requirements("coremltools>=6.0,<=6.2" if mlmodel else "coremltools>=7.0") + check_requirements("coremltools>=6.0,<=6.2" if mlmodel else "coremltools>=8.0") import coremltools as ct # noqa LOGGER.info(f"\n{prefix} starting export with coremltools {ct.__version__}...") diff --git a/ultralytics/utils/benchmarks.py b/ultralytics/utils/benchmarks.py index 20f7735414..2c7084d2c1 100644 --- a/ultralytics/utils/benchmarks.py +++ b/ultralytics/utils/benchmarks.py @@ -42,7 +42,7 @@ from ultralytics import YOLO, YOLOWorld from ultralytics.cfg import TASK2DATA, TASK2METRIC from ultralytics.engine.exporter import export_formats from ultralytics.utils import ARM64, ASSETS, LINUX, LOGGER, MACOS, TQDM, WEIGHTS_DIR -from ultralytics.utils.checks import IS_PYTHON_3_12, check_imgsz, check_requirements, check_yolo, is_rockchip +from ultralytics.utils.checks import IS_PYTHON_3_13, check_imgsz, check_requirements, check_yolo, is_rockchip from ultralytics.utils.downloads import safe_download from ultralytics.utils.files import file_size from ultralytics.utils.torch_utils import get_cpu_info, select_device @@ -119,7 +119,7 @@ def benchmark( "CoreML and TF.js export only supported on macOS and non-aarch64 Linux" ) if i in {5}: # CoreML - assert not IS_PYTHON_3_12, "CoreML not supported on Python 3.12" + assert not IS_PYTHON_3_13, "CoreML not supported on Python 3.13" if i in {6, 7, 8}: # TF SavedModel, TF GraphDef, and TFLite assert not isinstance(model, YOLOWorld), "YOLOWorldv2 TensorFlow exports not supported by onnx2tf yet" if i in {9, 10}: # TF EdgeTPU and TF.js diff --git a/ultralytics/utils/checks.py b/ultralytics/utils/checks.py index 4ce167f68d..21b2528f32 100644 --- a/ultralytics/utils/checks.py +++ b/ultralytics/utils/checks.py @@ -891,3 +891,4 @@ check_torchvision() # check torch-torchvision compatibility # Define constants IS_PYTHON_MINIMUM_3_10 = check_python("3.10", hard=False) IS_PYTHON_3_12 = PYTHON_VERSION.startswith("3.12") +IS_PYTHON_3_13 = PYTHON_VERSION.startswith("3.13")