| --- |
| license: agpl-3.0 |
| library_name: coremltools |
| pipeline_tag: object-detection |
| base_model: Ultralytics/YOLOv8 |
| tags: |
| - coreml |
| - apple-silicon |
| - yolo |
| - object-detection |
| - macos |
| --- |
| |
| # YOLOv8 Object Detection — Core ML |
|
|
| Ready-to-use Core ML conversions of Ultralytics YOLOv8 for object detection 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 are used by [Hugging Mac](https://github.com/devilyouwei/hugging-mac), an open-source platform for building and experiencing local AI apps, services, games, plugins, and agents on macOS. |
|
|
| ## Models |
|
|
| | Variant | Parameters | Package size | Best for | |
| |---|---:|---:|---| |
| | `yolov8n` | 3.2M | 6.5 MB | Lowest latency and resource usage | |
| | `yolov8s` | 11.2M | 22.5 MB | Balanced speed and accuracy | |
| | `yolov8m` | 25.9M | 52.0 MB | Higher accuracy | |
|
|
| ## Provenance and conversion |
|
|
| - Source: [Ultralytics/YOLOv8](https://huggingface.co/Ultralytics/YOLOv8) |
| - Source revision: `8a9e1a5` |
| - Task: COCO 80-class object detection |
| - Input size: fixed `640 × 640`, batch size 1 |
| - Precision: FP16 conversion |
| - NMS: not embedded; apply confidence filtering and NMS after inference |
|
|
| ## Input and output |
|
|
| | Name | Type | Shape | Description | |
| |---|---|---|---| |
| | `image` | RGB image | `640 × 640` | Letterboxed model input | |
| | `predictions` | FP32 multi-array | `1 × 84 × 8400` | Boxes and scores for 80 COCO classes | |
|
|
| The first four output channels contain bounding boxes in `x, y, width, height` form. The remaining 80 channels contain class scores. Resize boxes back to the original image after confidence filtering and class-aware NMS. |
|
|
| ## Core ML example |
|
|
| ```python |
| from pathlib import Path |
| |
| import coremltools as ct |
| from huggingface_hub import snapshot_download |
| from PIL import Image, ImageOps |
| |
| root = Path(snapshot_download( |
| repo_id="hugging-mac/yolov8-coreml", |
| allow_patterns=["yolov8n.mlpackage/**"], |
| )) |
| |
| model = ct.models.MLModel( |
| root / "yolov8n.mlpackage", |
| compute_units=ct.ComputeUnit.ALL, |
| ) |
| |
| image = Image.open("image.jpg").convert("RGB") |
| image = ImageOps.pad(image, (640, 640), color=(114, 114, 114)) |
| predictions = model.predict({"image": image})["predictions"] |
| |
| print(predictions.shape) # (1, 84, 8400) |
| ``` |
|
|
| For a complete preprocessing, decoding, and NMS implementation, see the [Hugging Mac YOLOv8 SDK](https://github.com/devilyouwei/hugging-mac/tree/main/packages/hugging_mac_sdk/src/hugging_mac_sdk/models/yolov8). |
|
|
| ## Integrity |
|
|
| | Package | Directory SHA-256 | |
| |---|---| |
| | `yolov8n.mlpackage` | `c8eb62862dddac01512e47469e5dc15ad707d85c2d713d78a5b17b17d365f4a4` | |
| | `yolov8s.mlpackage` | `c5178bbaf83f8d4be513e2ce6f8081d44882466ab4a4eb62c704e1c9c95d3eac` | |
| | `yolov8m.mlpackage` | `d4e4e1a92b891cd8cfc3c41e15a57b92b26abc263deed6dc409874c1fbefe6a5` | |
|
|
| ## License |
|
|
| The converted models retain the upstream [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) licensing terms. They are published under AGPL-3.0. Review Ultralytics licensing requirements before commercial or closed-source use. |
|
|
| Hugging Mac is an independent open-source project and is not affiliated with or endorsed by Ultralytics. |
|
|