Ready-to-use Core ML conversions of Ultralytics YOLOv8 Seg for instance segmentation on Apple Silicon. The n, s, and m variants are provided as .mlpackage models for use with the CPU, GPU, and Apple Neural Engine.
These models power local computer-vision apps in
Hugging Mac, an open-source platform for building AI apps, services, games, plugins, and agents on macOS.
1from pathlib import Path
2
3import coremltools as ct
4from huggingface_hub import snapshot_download
5from PIL import Image, ImageOps
6
7root = Path(snapshot_download(
8 repo_id="hugging-mac/yolov8-seg-coreml",
9 allow_patterns=["yolov8n-seg.mlpackage/**"],
10))
11model = ct.models.MLModel(
12 root / "yolov8n-seg.mlpackage",
13 compute_units=ct.ComputeUnit.ALL,
14)
15image = ImageOps.pad(
16 Image.open("image.jpg").convert("RGB"),
17 (640, 640),
18 color=(114, 114, 114),
19)
20outputs = model.predict({"image": image})
21print(outputs["predictions"].shape) # (1, 116, 8400)
22print(outputs["prototypes"].shape) # (1, 32, 160, 160)
The outputs are raw. See the
Hugging Mac YOLOv8 Seg SDK for complete preprocessing, NMS, mask reconstruction, and coordinate restoration.
The converted models retain the upstream Ultralytics licensing terms and are published under AGPL-3.0. Review Ultralytics licensing requirements before commercial or closed-source use. Hugging Mac is not affiliated with or endorsed by Ultralytics.