Require coremltools>=8.0 (#19819)

This commit is contained in:
Glenn Jocher 2025-03-21 20:51:14 +01:00 committed by GitHub
parent 80e43dcf62
commit 3aba4203f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 9 additions and 8 deletions

View file

@ -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

View file

@ -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

View file

@ -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:

View file

@ -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__}...")

View file

@ -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

View file

@ -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")