Apple Core ML Export
Core ML is Apple's framework for running machine learning models on iPhone, iPad, Mac, Apple Watch, Apple TV, and Apple Vision Pro. Exporting an Ultralytics YOLO26 model with format="coreml" creates a yolo26n.mlpackage model package that Core ML runs on the CPU, the GPU, and the Apple Neural Engine, in FP32, in FP16, or with 8-bit weights.
Apple has introduced the new Core AI framework and .aimodel format for the iOS 27 and macOS 27 generation, and Ultralytics exports it with format="coreai". Core ML remains the default format of the Ultralytics iOS and Flutter SDKs, which load Core AI as an opt-in on iOS 27 devices, and the format for earlier Apple operating systems.
At a Glance#
| Property | Details |
|---|---|
format argument | coreml (aliases: mlpackage, mlprogram, apple, ios). mlmodel exports the earlier neural network format |
| Output | yolo26n.mlpackage, a model package (a directory) in the ML Program format, with the class names, task, and image size stored inside it as metadata |
| Runs on | iPhone, iPad, Mac, Apple Watch, Apple TV, and Apple Vision Pro, on the CPU, the GPU, and the Apple Neural Engine |
| Runtime | Core ML, which is built into Apple's operating systems; the exported ML Program declares Core ML specification 6 (iOS 15, macOS 12) or, for INT8, specification 7 (iOS 16, macOS 13). In Python, the coremltools package on macOS |
| Precision | FP32, FP16, INT8 (8-bit weights). YOLO26n is 9.9 MB in FP32, 5.1 MB in FP16, and 2.7 MB in INT8 |
| Export host | macOS, or Linux x86-64, with Python 3.13 or older. Not Windows. The export needs no GPU |
Ultralytics Platform can export a trained model to Core ML for you, so you do not need a local export environment.
Quickstart#
Install the Ultralytics package with the Core ML export dependencies, on macOS or on x86-64 Linux:
pip install "ultralytics[export-coreml]"This installs coremltools, scikit-learn, and a numpy version that coremltools works with. With a plain pip install ultralytics, the first export installs coremltools, and when it also has to replace a newer numpy, that export fails; the next one passes. The export has these version requirements:
| Package | Required version |
|---|---|
| Python | 3.13 or older, the newest version that coremltools 9.0 has prebuilt packages for |
coremltools | 9.0 or newer |
numpy | 2.3.5 or older. The export installs 2.3.5 over a newer version |
torch | 1.11 or newer |
scikit-learn | For quantize=8 and 'w8a16' only. The export-coreml extra installs 1.3.2 or newer, and the export installs it if it is missing |
For other installation methods, see the installation guide. Then export your model and load the exported package to run inference or validate its accuracy.
from ultralytics import YOLO
# Load a YOLO26 model
model = YOLO("yolo26n.pt")
# Export the model to Core ML format
model.export(format="coreml") # creates 'yolo26n.mlpackage'
# Or export in FP16 instead, which halves the size and runs on the Neural Engine
model.export(format="coreml", quantize=16) # creates 'yolo26n.mlpackage'Both exports write the same yolo26n.mlpackage, so the second one replaces the first. Predict and Validate run only on macOS:
from ultralytics import YOLO
# Load the exported Core ML model on a Mac
model = YOLO("yolo26n.mlpackage")
# Run inference
results = model("https://ultralytics.com/images/bus.jpg")from ultralytics import YOLO
# Load the exported Core ML model on a Mac
model = YOLO("yolo26n.mlpackage")
# Validate accuracy on the COCO8 dataset
metrics = model.val(data="coco8.yaml")Supported Tasks#
Core ML export supports all seven Ultralytics tasks with YOLOv8, YOLO11, and YOLO26 models: detection, segmentation, semantic segmentation, depth estimation, classification, pose estimation, and OBB. Semantic segmentation and depth estimation are available only with YOLO26, the only family that ships those heads. Detection models of YOLOv5u, YOLOv9, YOLOv10, and YOLO12 export too, as do RT-DETR and YOLO-Worldv2 models. Each was tested with one checkpoint per task, for example yolo11n-seg.pt, rtdetr-l.pt, and yolov8s-worldv2.pt.
Export Arguments#
| Argument | Type | Default | Description |
|---|---|---|---|
format | str | 'coreml' | Target format for the exported model, defining compatibility with various deployment environments. |
imgsz | int or tuple | 640 | Image size of the model input, fixed in a default export: an integer for square images or a tuple (height, width). When not passed, the export uses the size the checkpoint was trained at. The official YOLO26 checkpoints use 640 for detect, segment, and pose models and for semantic models pretrained on ADE20K, 1024 for OBB models and for semantic models pretrained on Cityscapes, 768 for depth, and 224 for classify. |
quantize | int or str | None | Precision: 16 (FP16) or 8 (8-bit weights with FP16 computation; 'w8a16' is the same export); 32/unset is FP32. With nms=True, unset is FP16. A checkpoint trained with quantize=8 cannot be exported to Core ML, see Limitations and Troubleshooting. Replaces the deprecated half/int8 flags. |
nms | bool, optional | None | Select raw output (None, default), embedded NMS (True, for detect, segment, and pose models with dynamic=False), or the NMS-free head (False). See output format. |
conf | float | None | Confidence threshold stored in an nms=True export. Uses 0.25 when unset. |
iou | float | 0.5 | IoU threshold stored in an nms=True export. |
agnostic_nms | bool | False | Class-agnostic selection: in an nms=True export a box suppresses overlapping boxes of other classes too. It also changes the selection of the rows of an nms=False export. |
max_det | int | 300 | Number of rows in the output of an nms=False export and of an nms=True segmentation or pose export. An nms=True detection export has no such limit. |
dynamic | bool | False | Makes the batch size, height, and width of the input dynamic, and changes the input from an image to an array. Not available for classification and RT-DETR models or with nms=True. See Deploy. |
batch | int | 1 | Largest batch size of a dynamic=True export. A default export has a batch size of 1, and other values raise an error. |
device | str | None | Device that traces the model for the conversion, cpu by default. An FP32 export traced with mps had the same package size and returned the same outputs as one traced on the CPU. |
For the arguments shared by all formats, see the Export mode documentation.
The official Core ML, LiteRT, and QNN mobile models are exported at imgsz=640, and at imgsz=224 for classification. The Cityscapes semantic, depth, and OBB checkpoints export at a larger size by default, so pass imgsz=640 to match them. The Core ML models of the Ultralytics iOS SDK are exported with quantize=8 nms=False.
Precision#
quantize selects how the weights are stored and the precision Core ML computes in. None of the three precisions needs calibration data. The sizes are for a YOLO26n detection model exported at imgsz=640:
quantize | Weights | Computation | Minimum OS | YOLO26n size |
|---|---|---|---|---|
unset or 32 | FP32 | FP32 | iOS 15, macOS 12 | 9.9 MB |
16 | FP16 | FP16 | iOS 15, macOS 12 | 5.1 MB |
8 or 'w8a16' | 8-bit | FP16 | iOS 16, macOS 13 | 2.7 MB |
- FP32: the default when
nms=Trueis not set. On an Apple M4, the FP32 exports of all seven tasks returned the same outputs with theCPU_AND_NEcompute units, which Ultralytics uses, as withCPU_ONLY, and were not faster with them. Export in FP16 or INT8 to use the Neural Engine. On an iPhone 17 Pro, an FP32 YOLO26n detection model was at most 5% faster with the Neural Engine by the median of three runs, see Measured Performance. - FP16:
quantize=16stores the weights and computes in half precision. The image input and the output arrays keep the types of the FP32 export (float32, orint32for semantic segmentation), so inference code written for the FP32 model runs it unchanged. - INT8:
quantize=8andquantize="w8a16"are the same export. It groups the weights of each layer into 256 values with k-means and stores an 8-bit index for every weight (palettization), and computes in FP16 like an FP16 export. Weight tensors with 512 values or fewer are not palettized. This is weight compression and not the calibrated activation quantization thatquantize=8selects for other formats, so it takes nodataargument. Withscikit-learnalready installed, the export of a YOLO26n detection model took 18 to 26 s on an Apple M4 and 23 to 24 s on an x86-64 server, and the export of YOLO26x took 104 s on that server. - Accuracy: see the Apple M4 tables for COCO results in each precision. Validate an exported model on your own data before you deploy it.
Output Format#
The export writes one package, a directory that Xcode, Core ML, and coremltools open as a single model:
File in yolo26n.mlpackage/ | Contents |
|---|---|
Manifest.json | The list of the files in the package |
Data/com.apple.CoreML/model.mlmodel | The network graph, the input and output descriptions, and the metadata: class names, task, image size, batch size, stride, and export arguments, which Ultralytics reads when it loads the model |
Data/com.apple.CoreML/weights/weight.bin | The weights |
The model takes one input named image. For a default export it is a Core ML image input: an RGB image of the export imgsz with pixel values from 0 to 255. The division by 255 is part of the model, so do not scale the image yourself, and in an app Apple's Vision framework can resize a camera frame to this input. An export with dynamic=True takes a float32 array of shape (batch, 3, height, width) instead, RGB and scaled to 0-1.
The names of the output arrays are generated by the converter, such as var_1401, and change between models and export settings, so read them from the model description instead of hard-coding them. The nms argument and the task set the outputs. The shapes below are for the official YOLO26n checkpoints at their default export size, with the Cityscapes checkpoint yolo26n-sem.pt for semantic segmentation:
| Task | Default imgsz | Output with nms=None | Output with nms=False | Output with nms=True |
|---|---|---|---|---|
| Detect | 640 | (1, 84, 8400) | (1, 300, 6) | confidence (boxes, 80) and coordinates (boxes, 4) |
| Segment | 640 | (1, 116, 8400) and (1, 32, 160, 160) | (1, 300, 38) and (1, 32, 160, 160) | (1, 300, 38) and (1, 32, 160, 160) |
| Semantic | 1024 | (1, 1024, 1024), class index for each pixel | Same as nms=None | Same as nms=None |
| Depth | 768 | (1, 1, 768, 768), depth map | Same as nms=None | Same as nms=None |
| Classify | 224 | classLabel and classLabel_probs | Same as nms=None | Same as nms=None |
| Pose | 640 | (1, 56, 8400) | (1, 300, 57): 6 box values, then 17 keypoints x 3 | (1, 300, 57) |
| OBB | 1024 | (1, 20, 21504) | (1, 300, 7): 4 box values, score, class, angle | Same as nms=None |
- Raw output (
nms=None): shape(1, values, anchors), the same raw predictions as a default ONNX export: for each anchor the box center x, center y, width, and height in input pixels, then the class scores, then the values of the task (32 mask coefficients, 17 x 3 keypoint values, or the OBB angle in radians). Apply NMS yourself. - NMS-free output (
nms=False):max_det(default 300) rows ofx1, y1, x2, y2, score, classin input pixels, with no NMS step. OBB rows arecenter x, center y, width, height, score, class, angle. Filter the rows by score. Available for models with an NMS-free head, such as YOLO26 and YOLOv10. - Embedded NMS for detection (
nms=True): the package is a Core ML pipeline of the model and Apple's NMS stage. It returnsconfidence, one row of class scores for each kept box, andcoordinates, the box center x, center y, width, and height of each kept box relative to the image size (0-1). The number of rows changes from image to image.conf(default0.25),iou(default0.5), andagnostic_nmsare stored in the pipeline at export, and the inputsconfidenceThresholdandiouThreshold, which can be left out, replace the two thresholds for one prediction.max_detdoes not apply: an export withmax_det=2still returned five boxes for a test image. For a model whose number of classes is not a multiple of 80, the export padsconfidencewith extra columns up to the next multiple of 80. - Embedded NMS for segmentation and pose (
nms=True): NMS runs inside the model graph, which returnsmax_detrows ofx1, y1, x2, y2, score, classfollowed by the mask coefficients or keypoints. Rows past the last detection have a score of 0, so filter the rows by score.conf,iou,agnostic_nms, andmax_detare fixed at export, and these exports are always FP16 or INT8. - Segmentation: the 3-D output holds the predictions and the 4-D output the mask prototypes.
- Semantic segmentation: the output is the class index of every pixel as
int32, not a score for each class. - Classification: the package is a Core ML classifier, which returns
classLabel, the name of the top class, andclassLabel_probs, a dictionary of class names and probabilities.coremltoolsalso returns the probabilities as a(1, classes)array.
YOLO("yolo26n.mlpackage") reads the layout from the model metadata, so you only need these details when you run the model in your own code. The metadata is stored as strings in the user-defined metadata of the model. Its keys include names, task, imgsz, stride, batch, end2end, args, and, for pose models, kpt_shape.
Run with coremltools#
To run the package outside the Ultralytics package on a Mac, load it with coremltools, which also selects the compute units:
# Export first: yolo export model=yolo26n.pt format=coreml quantize=16 nms=False
import ast
import coremltools as ct
import numpy as np
from PIL import Image
model = ct.models.MLModel("yolo26n.mlpackage", compute_units=ct.ComputeUnit.CPU_AND_NE)
image = Image.fromarray(np.zeros((640, 640, 3), dtype=np.uint8)) # your letterboxed image: RGB, 0-255
outputs = model.predict({"image": image})
detections = next(iter(outputs.values()))[0] # the only output array, first image: shape (300, 6)
assert detections.shape == (300, 6), "export a detection model at imgsz=640 with nms=False"
detections = detections[detections[:, 4] > 0.25] # keep rows above the confidence threshold
names = ast.literal_eval(model.user_defined_metadata["names"]) # {0: 'person', 1: 'bicycle', ...}Deploy#
On an iPhone or iPad, add the .mlpackage to your Xcode project, or use the Ultralytics iOS SDK, which loads it and decodes the outputs for you. On a Mac, install the package with pip install ultralytics and copy the .mlpackage to it: YOLO("yolo26n.mlpackage") runs the model with coremltools, which Ultralytics installs on first use.
- Compute units: Ultralytics loads a model with the Core ML compute units
CPU_AND_NE, the CPU and the Neural Engine, and RT-DETR models withALL. If the model does not load with them, it loads withCPU_ONLY. There is no argument to choose other compute units; load the package withcoremltoolsto do that. On an Apple M4 with macOS 27.2,ALLandCPU_AND_GPUalso ran the FP32, FP16, and INT8 models of all seven YOLO26n tasks; other macOS versions were not tested. device: thedeviceargument does not select the Core ML hardware. Withdevice="mps"Ultralytics preprocesses and postprocesses on the Apple GPU while Core ML still uses the same compute units. On an M4 this did not make inference faster: an FP16 YOLO26n model took about 8 ms per image withdevice="mps"against about 6 ms without it, so leavedeviceunset.- Precision and the Neural Engine: on an Apple M4, the inference stage of
YOLO()took 18 to 20 ms per image inpredictfor an FP32 YOLO26n model (21.0 ms in the COCO validation in Apple M4) and about 6 ms for the FP16 and INT8 models, for default (nms=None) exports on one test image with macOS 27.2. Withcoremltoolsalone, the same FP16 and INT8 models took about 2 ms withCPU_AND_NEagainst 9 to 10 ms withCPU_ONLY. - Fixed input shape: a default export always runs at its export
imgsz, which Ultralytics reads from the model metadata. Animgszpassed topredictorvalis ignored. Ultralytics passes each image of a batch to Core ML as a separate single-image request, so any number of images works, andvalsetsbatch=1. - Dynamic export (
dynamic=True): the model declares batch sizes from 1 to the exportbatchand image sizes from 32 pixels to twice the exportimgsz, and Ultralytics passes image sizes in multiples of the model stride. Ultralytics splits larger batches into chunks of the exportbatch. With the NMS-free head the smallest size is larger, 128 pixels for a YOLO26n model exported atimgsz=640withnms=False. Tested with a detection model at 320, 640, and 1280 pixels and with a segmentation model at 640.
Ultralytics iOS SDK and Flutter Plugin#
The Ultralytics iOS SDK is a Swift package that loads Core ML exports of all seven YOLO26 tasks and returns decoded results. Export with the settings of the official app models:
# INT8 weights and the NMS-free head; use imgsz=224 for classification models
yolo export model=yolo26n.pt format=coreml quantize=8 nms=False imgsz=640Add https://github.com/ultralytics/yolo-ios-app.git to your app with Swift Package Manager, then load the exported package:
import UltralyticsYOLO
// Load your exported Core ML model, then run inference on a UIImage
let yolo = YOLO("/path/to/yolo26n.mlpackage", task: .detect) { result in
if case .success(let model) = result {
let results = model(uiImage) // boxes, labels, confidences, timing
}
}The SDK runs Core ML models through Vision's VNCoreMLRequest, which scales each image to the model input. For camera apps, the SDK's YOLOView runs real-time inference with native overlays, and the Ultralytics YOLO Flutter plugin runs the same Core ML exports on iOS from a codebase shared with Android. The SDK asks Core ML for .cpuAndNeuralEngine on iOS 16 and later instead of .all, because in a camera app the GPU is already busy with the preview and the overlays.
Deployment Guides#
- Integrating a Core ML Model into Your App: Apple's guide to adding a model to an Xcode project and calling it.
- Recognizing Objects in Live Capture: Apple's sample for running a Core ML detector on camera frames with Vision and
VNCoreMLRequest. - MLComputeUnits: the
computeUnitssetting ofMLModelConfigurationthat selects the CPU, the GPU, and the Neural Engine. - Optimize your Core ML usage: Apple's session on Xcode performance reports, which show the compute unit and latency of each layer on a device.
- Core ML Tools guide: the conversion and optimization reference for the
coremltoolspackage that this export uses. - Ultralytics Platform: open a Core ML export in the Ultralytics YOLO app on an iPhone by scanning a QR code.
- Core AI, LiteRT, and Qualcomm QNN: Apple's format for iOS 27 and the formats for Android devices and Snapdragon NPUs.
Limitations and Troubleshooting#
- First export after a plain install: when the first export has to replace
numpy(versions above 2.3.5 break the conversion), Ultralytics logsRestart runtime or rerun command for updates to take effectand that export fails withTypeError: only 0-dimensional arrays can be converted to Python scalars. Run the export again in a new process, which means a kernel restart in a notebook, or install"ultralytics[export-coreml]"before the first export as in the Quickstart. - Export host: the export runs on macOS and on x86-64 Linux. It is not supported on Windows or on ARM64 Linux, such as a Raspberry Pi:
coremltools9.0 publishes prebuilt packages for macOS and x86-64 Linux only. - Python version:
coremltools9.0 has prebuilt packages for Python 3.13 and older. On Python 3.14,pip install "ultralytics[export-coreml]"installs none of the Core ML packages, so the export buildscoremltoolsfrom source. The first export then fails as after a plain install, and the next one withRuntimeError: BlobWriter not loaded. Create the environment with Python 3.13 or older. - Inference needs macOS: on Linux, predicting or validating with
YOLO("yolo26n.mlpackage")fails withModel prediction is only supported on macOS version 10.13 or later.Validate the PyTorch checkpoint there, or copy the package to a Mac. - Automatic installation turned off: with
YOLO_AUTOINSTALL=false, the export fails withNo module named 'coremltools'in an environment without the package. - Checkpoints trained with
quantize=8: a checkpoint fine-tuned with quantization-aware training fails withformat='coreml' cannot export a QAT model: its Q/DQ ranges are only read by the 'onnx' and 'engine' backends. Export the checkpoint you started the fine-tuning from withquantize=8instead, or export the fine-tuned checkpoint to ONNX or TensorRT. quantize="w8a32": fails withquantize='w8a32' is not supported; format='coreml' supports quantize=16 (FP16), 8 (INT8), 'w8a16' (INT8 weights + INT16 activations), 32 or None (FP32).For Core ML,'w8a16'is the same export as8, with FP16 computation.- Embedded NMS on other tasks:
nms=Trueworks for detect, segment, and pose models. For OBB and classification models the export logsCoreML 'nms=True' is only supported for detect, segment and pose models. Forcing 'nms=None'., for semantic segmentation and depth estimation models'nms=True' is not valid for semantic models. Forcing 'nms=None'.(ordepth models), and for RT-DETR models'nms=True' is not available for end2end models or non-YOLO heads. Forcing 'nms=None'.All of them write the output of a default export. - Embedded NMS precision: an
nms=Trueexport withoutquantizeis FP16.quantize=32gives an FP32 pipeline for a detection model, and for segmentation and pose models the export logsCoreML 'nms=True' requires FP16 for segment models. Forcing 'quantize=16'.(orpose models) - Embedded NMS and validation: an
nms=Trueexport removes boxes below itsconfbeforevalsees them, so it scores lower than the same model with external NMS: on COCO val2017, an FP16 YOLO26n export withnms=Truereached 33.8 mAPval 50-95 with the defaultconf=0.25and 39.9 when exported withconf=0.001, still 1.0 below the 40.9 of a default FP16 export. Export withconf=0.001to validate such a model, and choose the deployment threshold separately. - NMS-free head on other models:
nms=Falseneeds a model with an NMS-free head, such as YOLO26 or YOLOv10. For other models, for example YOLO11, the export warnsThis model has no one-to-one head; using one-to-many outputs.and writes the raw(1, 84, 8400)output. - Batch size: a
batchabove 1 withoutdynamic=Truefails withbatch sizes > 1 are not supported without 'dynamic=True' for CoreML export. Please retry at 'dynamic=True'. - Dynamic shapes:
dynamic=Truewithoutbatchlogs'dynamic=True' export requires a maximum batch size, e.g. 'batch=16'.and exports a model with a maximum batch size of 1. Withnms=Trueit fails with'nms=True' cannot be used together with 'dynamic=True' for CoreML export. Please disable one of them., and for classification and RT-DETR models with'dynamic=True' is not supported for CoreML classification or RT-DETR models.An image size outside the range fails at prediction with an error such asSize (1312) of dimension (2) is not in allowed range (32..1280). - Semantic segmentation on the Neural Engine: on an Apple M4, a YOLO26n-sem model took longer with
CPU_AND_NEthan withCPU_ONLY, withcoremltoolsalone on one test image: 59 to 64 ms against 22 ms for the FP16 export atimgsz=1024, and about 15 ms against 9 ms for the INT8 export atimgsz=640. The FP16 models of the other six tasks, and their INT8 models atimgsz=640(224 for classification), ran faster withCPU_AND_NE, and on the iPhone 17 Pro the INT8 semantic model was faster with the Neural Engine too.YOLO()always usesCPU_AND_NEfor these models, so measure a semantic model with both settings in your own code. .cpuOnlyon iOS 27.0.1: on an iPhone 17 Pro,.cpuOnlyinference of the YOLO26l and YOLO26x depth, pose, and OBB models crashed inside Core ML's CPU kernels (EXC_BAD_ACCESSinlibBNNS). They run with.cpuAndNeuralEngine, which the iOS SDK requests.- Package name: every export of one checkpoint writes the same
yolo26n.mlpackage, whatever itsquantize,imgsz,nms, ordynamic, so the later export replaces the earlier one. Rename the package to keep both, and keep the.mlpackagesuffix, for exampleyolo26n_fp16.mlpackage, because Ultralytics recognizes the format by it. A package without the suffix fails withis not a supported model format. - PyTorch version warning: with a recent PyTorch,
coremltoolslogsTorch version 2.15.0 has not been tested with coremltools. You may run into unexpected errors.when it loads, and with a recentscikit-learnit logsscikit-learn version 1.9.1 is not supported.The exports and Mac results on this page were made with these versions. - Legacy
.mlmodelfiles:format="mlmodel"exports the earlier Core ML neural network format as a singleyolo26n.mlmodelfile for apps that cannot load an ML Program. There,quantize=8and'w8a16'apply linear 8-bit weight quantization. Use the default.mlpackagefor new projects.
For other errors, see the Common Issues guide.
Measured Performance#
The tables below were measured on an iPhone 17 Pro and on an Apple M4 Mac. The YOLO26 model page lists the accuracy of the PyTorch checkpoints for every task.
iPhone 17 Pro#
Hardware: iPhone 17 Pro with iOS 26.6. Its A19 Pro has a 6-core CPU (2 Performance and 4 Efficiency cores), a 6-core GPU, and a 16-core Neural Engine.
The first table gives the latency of one image for the official INT8 model of each task, the v8.3.0 assets of the Ultralytics iOS SDK, which are exported with nms=False. Each cell shows the total time in milliseconds with the preprocess / inference / postprocess split beneath it; the faster compute unit is in bold:
| Model | Task | size (pixels) | CPU Core ML .cpuOnly(ms) | CPU + Neural Engine Core ML .cpuAndNeuralEngine(ms) |
|---|---|---|---|---|
| YOLO26n | Detect | 640 | 9.7 0.0 / 9.7 / 0.0 | 4.7 0.0 / 4.7 / 0.0 |
| YOLO26n-seg | Segment | 640 | 12.8 0.0 / 12.2 / 0.6 | 5.8 0.0 / 5.0 / 0.7 |
| YOLO26n-sem | Semantic | 640 | 9.3 0.0 / 8.9 / 0.5 | 5.3 0.0 / 4.8 / 0.5 |
| YOLO26n-depth | Depth | 640 | 25.8 0.0 / 24.8 / 1.0 | 8.0 0.0 / 6.9 / 1.1 |
| YOLO26n-cls | Classify | 224 | 2.1 0.0 / 2.0 / 0.0 | 1.8 0.0 / 1.8 / 0.0 |
| YOLO26n-pose | Pose | 640 | 11.9 0.0 / 11.9 / 0.0 | 5.4 0.0 / 5.4 / 0.0 |
| YOLO26n-obb | OBB | 640 | 10.6 0.0 / 10.6 / 0.0 | 4.9 0.0 / 4.9 / 0.0 |
The same measurement for the five detection models, with the time the SDK takes to load each model:
| Model | CPU.cpuOnly(ms) | CPU + Neural Engine.cpuAndNeuralEngine(ms) | Model load.cpuAndNeuralEngine(s) |
|---|---|---|---|
| YOLO26n | 9.2 | 4.5 | 0.9 |
| YOLO26s | 19.5 | 10.5 | 1.3 |
| YOLO26m | 46.7 | 11.8 | 1.8 |
| YOLO26l | 60.1 | 12.0 | 2.4 |
| YOLO26x | 125.9 | 20.5 | 3.3 |
YOLO26n detection in the three precisions and with two nms settings, exported with ultralytics 8.4.215 at imgsz=640, as the total time in milliseconds:
| Precision | nms=None, CPU | nms=None, CPU + Neural Engine | nms=False, CPU | nms=False, CPU + Neural Engine |
|---|---|---|---|---|
| FP32 | 15.5 | 14.7 | 14.5 | 14.4 |
| FP16 | 9.2 | 4.9 | 9.2 | 5.0 |
| INT8 | 9.2 | 4.2 | 9.1 | 5.0 |
- Method: mean of 15 predictions after 3 warmup predictions on
bus.jpg, through the Swift SDK 8.9.23 in a release build..cpuOnlyand.cpuAndNeuralEngineare the Core ML compute units the SDK requests, and Core ML decides where each layer runs. Every table was measured in three separate runs and shows the median. The three runs agreed within 15%, except YOLO26n with.cpuAndNeuralEngine, which took 2.6 to 4.8 ms in the size table and 3.8 to 4.8 ms as the INT8nms=Noneexport. The task and size tables use the officialv8.3.0assets, and the precision table uses exports made withultralytics8.4.215, so their YOLO26n cells differ, by up to 0.5 ms with the Neural Engine and 0.6 ms on the CPU. - Preprocessing: Vision scales the image inside the inference request, so preprocessing is reported as 0 and its cost is part of inference.
- FP32: by these medians the FP32 export was at most 5% faster with
.cpuAndNeuralEnginethan with.cpuOnly, while FP16 and INT8 were about twice as fast. Export in FP16 or INT8 for the Neural Engine. nms: for YOLO26n detection, the NMS-free head (nms=False) and the raw output with NMS in the SDK (nms=None) both took 4 to 5 ms with the Neural Engine in FP16 and INT8.- Camera apps: these are single-image latencies. A real-time camera app adds capture and display time; see the iOS SDK performance notes.
- Compare Android CPU/GPU results in the LiteRT integration, MediaTek Dimensity results, and Snapdragon NPU results in the Qualcomm QNN integration.
Apple M4#
The tables below compare PyTorch with FP32, FP16, and INT8 Core ML models of every YOLO26 detection model on an Apple M4 (4 performance and 6 efficiency cores) with macOS 27.2, validated through YOLO() on COCO val2017. PyTorch ran on the CPU with 8 threads, batch=1, and rect=False, so that it sees the same 640x640 input as the Core ML models, which ran with the default compute units of Ultralytics.
Milliseconds per image, lower is better. The fastest format for each model is in bold.
| Model | imgsz | PyTorch | Core ML FP32 | Core ML FP16 | Core ML INT8 |
|---|---|---|---|---|---|
| YOLO26n | 640 | 25.6 | 21.0 | 6.0 | 6.0 |
| YOLO26s | 640 | 60.0 | 50.0 | 7.9 | 7.6 |
| YOLO26m | 640 | 137.2 | 127.6 | 14.3 | 11.3 |
| YOLO26l | 640 | 191.2 | 187.7 | 17.2 | 13.5 |
| YOLO26x | 640 | 341.1 | 334.2 | 28.6 | 24.3 |
With the NMS-free head (nms=False), YOLO26n reached 40.3 mAPval 50-95 in PyTorch and in FP32, 40.2 in FP16, and 40.1 in INT8.
The latency of YOLO26n with each Core ML compute unit, measured with coremltools alone as the median of 20 predictions on one image, in milliseconds:
| Precision | CPU_ONLY | CPU_AND_NE | ALL | CPU_AND_GPU |
|---|---|---|---|---|
| FP32 | 13.7 | 13.6 | 8.3 | 8.0 |
| FP16 | 9.6 | 1.8 | 2.0 | 7.7 |
| INT8 | 9.4 | 1.8 | 1.8 | 8.1 |
- FP16 and INT8 ran 3.5 to 14 times faster than FP32 through
YOLO(), at an accuracy within 0.1 mAP of FP32 for FP16 and within 0.2 for INT8. INT8 was as fast as FP16 for YOLO26n and up to 1.3 times faster for the larger models. - FP32 gave the same outputs with
CPU_AND_NEas withCPU_ONLY. Only the GPU compute units made it faster. - INT8 made the package 3.7 to 4.0 times smaller than FP32.
Measured with ultralytics 8.4.215, coremltools 9.0, and PyTorch 2.15.0 at batch=1 on November 17, 2026. Latency is the inference stage that val reports and does not include preprocessing or postprocessing. A second run of the three YOLO26n Core ML cases on the same day differed by up to 2.3 ms, 21.0 against 18.8 ms for FP32.
About Core ML#
Core ML is built into iOS, iPadOS, macOS, watchOS, tvOS, and visionOS. It loads models in the ML Program format, the .mlpackage this export writes, and runs each layer on the CPU, the GPU, or the Apple Neural Engine, the NPU of Apple silicon, so inference works offline and the data stays on the device. For the full reference, see the Core ML documentation.
Watch: How to Export Ultralytics YOLO26 to CoreML with INT8 Quantization | Apple Deployment | iOS/MacOS ๐
FAQ#
Both run on the Neural Engine and compute in FP16, so the choice is about size. FP16 (
quantize=16) halves the package, 5.1 MB against 9.9 MB for YOLO26n, and INT8 (quantize=8) stores 8-bit weights, 2.7 MB for YOLO26n, and is the precision of the official Ultralytics app models. On COCO val2017, a default YOLO26n export reached 40.9 mAPval 50-95 in FP16 and 40.8 in INT8 on an Apple M4, and both took about the same time per image there. On an iPhone 17 Pro both took 4 to 5 ms for YOLO26n with the Neural Engine, within the run-to-run variation. INT8 needs iOS 16 or macOS 13, while FP16 also runs on iOS 15 and macOS 12. Neither needs calibration data. Avoid the default FP32 export for deployment: it is the largest and was at most 5% faster with the Neural Engine compute units than on the CPU alone in our tests, see Precision. Validate the exported model on your own data and device before you ship it.It depends on who decodes the output. With the Ultralytics iOS SDK or the Flutter plugin, export YOLO26 models with
nms=False, as the official models are: the SDK then reads the final detections of the NMS-free head and needs no NMS step. On COCO val2017, YOLO26n in INT8 reached 40.1 mAPval 50-95 with the NMS-free head against 40.8 with the default output and external NMS. On an iPhone 17 Pro both took 4 to 5 ms per image. With Apple's Vision framework and your own code,nms=Trueturns a detection model into a Core ML pipeline with Apple's NMS stage, whose thresholds you can change for each prediction. Vision returns its detections asVNRecognizedObjectObservationobjects, and the score of a box is theconfidenceof the observation. For annms=Truedetection model, SDK 8.9.23 and earlier report about 1.0, the confidence of the top label of each box, in place of the box scores; later versions report theconfidenceof the observation. The defaultnms=Nonereturns raw predictions and leaves NMS to your code. See Output Format for the outputs of each setting.You can export without one: the export runs on x86-64 Linux, and Ultralytics Platform exports in the cloud. Running the model needs Apple hardware, because Core ML is part of Apple's operating systems. On Linux and Windows, validate the PyTorch checkpoint or an ONNX export of it, then validate the Core ML model itself on a Mac, where
YOLO("yolo26n.mlpackage").val()runs it, or on the device.
Comments13
Ask a question, share your results, or help someone else.
Afool4U
Hello! I have trouble when I tried to export yolo11n.pt to coreml model with tracking. for example, the exist tracking method is like this:
# use YOLO tracking results = yolo_model.track(frame, persist=True, verbose=False)And I've export pt format and reloaded the new coreml format model like this:
model.export(format='coreml', nms=True, half=False) model = ct.models.MLModel('yolo11n.mlpackage')But when I tried to make a tracking on my camera stream, it seems that object 'model' have no attribute named 'track'. So how could I use tracking by a coreml format model? It's very important to me because the coreml model works well on my macbook.
Sebastianxhj
I used the example python code you guys gave. Why does output output confidence and coordination after converting my target detection model to mlpackage format. is it normal to not return processed images? Or is there something wrong with my export process.
Glenn JocherUltralytics@taeja7 the CoreML export returns raw detection outputs (confidence, coordinates) rather than processed images by design. This is normal behavior, as post-processing like bounding box rendering is typically handled within the application layer after inference. For implementation guidance, see the CoreML deployment documentation on handling model outputs in Apple apps.
smadsenjc
I have a trained model that is doing very well in Python, but once I convert it to CoreML
.mlpackageformat and run inference in Swift, the results are garbage on the same images.If I export with
nms=True, I get multiple overlapping bounding boxes back, similar-ish to when no NMS is done. The number of clusters matches the objects I expect, and they're kind of relatively positioned correctly, although the boxes themselves are too large and clustered in the wrong location. The predicted labels are right.If I export with
nms=False, I get a different result back fromVNCoreMLRequest: a singleVNCoreMLFeatureValueObservationinstead of an array ofVNRecognizedObjectObservation.I've used both coremltools 8.0 and 8.2. If I run inference in Python using the CoreML model, it's fine (with
nms=False;Truefails).This was working back in November, but I got side-tracked with other work. I haven't touched the model.
Glenn JocherUltralytics@smadsenjc for CoreML inference discrepancies between Python and Swift, ensure you're handling NMS parameters correctly in your Swift implementation. The CoreML export with
nms=Truerequires explicit IOU and confidence threshold inputs during inference - these must match your Python training parameters. We recommend verifying your Swift preprocessing matches Ultralytics' RGB channel ordering and normalization (scale=1/255, bias=[0,0,0]). For direct assistance with Apple's Vision framework implementation, refer to Apple's CoreML integration guide linked in our documentation.
CharanPrasadK
When I am Converting the Yolo .pt model to coreml model , mlpackage is creating and when I am checking it in the xcode the class labels are missing. For the core ml models in ultralytics github page class labels are there. If its solved i can test my custom yolo models. Thank you.
Glenn JocherUltralytics(edited)@CharanPrasadK it seems the class labels are not being included in your CoreML export. Ensure that your model is correctly labeled during training and export by checking the
namesattribute in the model. If the issue persists, please verify that you're using the latestultralyticspackage. For further details, refer to the CoreML export documentation. Let us know if you need additional assistance!
ChristalZhu
Still the same problem, this is the result of running in the terminal๏ผ PyTorch: starting from '/Users/doublepeng/Desktop/best.pt' with input shape (1, 3, 640, 640) BCHW and output shape(s) ((1, 37, 8400), (1, 32, 160, 160)) (6.5 MB)
CoreML: starting export with coremltools 7.2... CoreML: WARNING โ ๏ธ 'nms=True' is only available for Detect models like 'yolov8n.pt'. Tuple detected at graph output. This will be flattened in the converted model. Converting PyTorch Frontend ==> MIL Ops: 100%|โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ| 679/681 [00:00<00:00, 8273.25 ops/s] Running MIL frontend_pytorch pipeline: 100%|โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ| 5/5 [00:00<00:00, 157.94 passes/s] Running MIL default pipeline: 100%|โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ| 78/78 [00:00<00:00, 82.56 passes/s] Running MIL backend_mlprogram pipeline: 100%|โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ| 12/12 [00:00<00:00, 160.71 passes/s] CoreML: export success โ 7.7s, saved as '/Users/doublepeng/Desktop/best.mlpackage' (6.4 MB)
Export complete (8.1s) Results saved to /Users/doublepeng/Desktop Predict: yolo predict task=segment model=/Users/doublepeng/Desktop/best.mlpackage imgsz=640 Validate: yolo val task=segment model=/Users/doublepeng/Desktop/best.mlpackage imgsz=640 data=/home/yujialin/Documents/xiaotong/corn/data/corn.yaml Visualize: https://netron.app In the run mlpackage file, the class label is still missing in General, and there is no preview. Since I am only doing corn segmentation, if possible, can I send you my .pt file?
Glenn JocherUltralytics@ChristalZhu hello,
Thank you for providing the detailed output from your terminal. It looks like the CoreML export process completed successfully, but you're experiencing issues with missing class labels and preview in the
.mlpackagefile.To assist you better, could you please confirm the following:
- Are you using the latest versions of
torchandultralytics? If not, please upgrade and try the export process again. - Could you provide a minimum reproducible example of your code? This will help us understand the context and reproduce the issue on our end. You can refer to our minimum reproducible example guide for more details.
Regarding your
.ptfile, we cannot accept direct file submissions. However, you can share the relevant code snippets and configurations you used for training and exporting the model.Here's a quick example of how to export a YOLOv8 model to CoreML and run inference:
from ultralytics import YOLO # Load the YOLOv8 model model = YOLO("yolov8n.pt") # Export the model to CoreML format model.export(format="coreml") # creates 'yolov8n.mlpackage' # Load the exported CoreML model coreml_model = YOLO("yolov8n.mlpackage") # Run inference results = coreml_model("https://ultralytics.com/images/bus.jpg")For more detailed instructions, you can visit our CoreML integration guide.
Looking forward to your response so we can help resolve this issue.
- Are you using the latest versions of
ChristalZhu
ๆๆ็ งhttps://harshavardhanyellanki.github.io/YOLOV8_GUI/tasks/segmentation/็ๆนๆณ๏ผๅฐๆ่ชๅทฑ่ฎญ็ป็ๅๅฒๆจกๅ่ฟ่กๅฏผๅบๆmlpackage๏ผไฝๆฏๅบ็ฐไบ้ฎ้ขๅฐฑๆฏๆๅผ่ฟไธชmlpackageไนๅ๏ผ็ผบๅฐclass labelๆไปถๅ็ผบๅฐไบpreview๏ผ่ฏท้ฎ่ฟไธชๆไปไนๅๆณ่งฃๅณ๏ผๅฆๆๅฏไปฅ็่ฏ๏ผ้บป็ฆๅ้ๅฐๆ็email่ดฆๅท๏ผwenpeng.zhu@foxmail.comไธๅๆ่ฐขใ I followed the method at https://harshavardhanyellanki.github.io/YOLOV8_GUI/tasks/segmentation/ to export the segmentation model I trained myself into mlpackage, but the problem is that after opening this mlpackage, the class label file and the preview are missing. Is there any way to solve this problem? If possible, please send it to my email account: wenpeng.zhu@foxmail.com. Thank you very much.
Paula DerrengerUltralyticsHello @ChristalZhu,
Thank you for reaching out and providing details about the issue you're facing with exporting your YOLOv8 segmentation model to CoreML. Let's work together to resolve this.
Firstly, please ensure that you are using the latest versions of
torchandultralytics. You can update them using the following commands:pip install --upgrade torch ultralyticsIf the issue persists, could you please provide a minimum reproducible code example? This will help us better understand the problem and investigate a solution. You can refer to our guide on creating a minimum reproducible example here: Minimum Reproducible Example.
Regarding the missing class label file and preview in the
.mlpackage, this can sometimes occur if the export process does not include all necessary metadata. Here is a Python example to ensure the export includes all required components:from ultralytics import YOLO # Load your trained YOLOv8 model model = YOLO("path/to/your/custom_model.pt") # Export the model to CoreML format model.export(format="coreml", nms=True) # Ensure NMS is included for proper detectionAfter exporting, you can manually check the
.mlpackageto ensure it contains the necessary class labels and preview files. If they are still missing, please let us know, and we can further investigate.For more detailed instructions on exporting to CoreML, you can visit our documentation here: CoreML Export Guide.
Feel free to share any additional details or errors you encounter. We're here to help!
ChristalZhu
Still the same problem, this is the result of running in the terminal๏ผ PyTorch: starting from '/Users/doublepeng/Desktop/best.pt' with input shape (1, 3, 640, 640) BCHW and output shape(s) ((1, 37, 8400), (1, 32, 160, 160)) (6.5 MB)
CoreML: starting export with coremltools 7.2... CoreML: WARNING โ ๏ธ 'nms=True' is only available for Detect models like 'yolov8n.pt'. Tuple detected at graph output. This will be flattened in the converted model. Converting PyTorch Frontend ==> MIL Ops: 100%|โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ| 679/681 [00:00<00:00, 8273.25 ops/s] Running MIL frontend_pytorch pipeline: 100%|โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ| 5/5 [00:00<00:00, 157.94 passes/s] Running MIL default pipeline: 100%|โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ| 78/78 [00:00<00:00, 82.56 passes/s] Running MIL backend_mlprogram pipeline: 100%|โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ| 12/12 [00:00<00:00, 160.71 passes/s] CoreML: export success โ 7.7s, saved as '/Users/doublepeng/Desktop/best.mlpackage' (6.4 MB)
Export complete (8.1s) Results saved to /Users/doublepeng/Desktop Predict: yolo predict task=segment model=/Users/doublepeng/Desktop/best.mlpackage imgsz=640
Validate: yolo val task=segment model=/Users/doublepeng/Desktop/best.mlpackage imgsz=640 data=/home/yujialin/Documents/xiaotong/corn/data/corn.yaml
Visualize: https://netron.app In the run mlpackage file, the class label is still missing in General, and there is no preview. Since I am only doing corn segmentation, if possible, can I send you my .pt file?
Paula DerrengerUltralyticsHello @ChristalZhu,
Thank you for providing the detailed output from your terminal. It looks like the CoreML export process completed successfully, but you're encountering issues with missing class labels and preview in the
.mlpackage.To address this, please ensure you are using the latest versions of
torchandultralytics. You can update them using the following commands:pip install --upgrade torch ultralyticsIf the issue persists, could you please provide a minimum reproducible code example? This will help us better understand the problem and investigate a solution. You can refer to our guide on creating a minimum reproducible example here: Minimum Reproducible Example.
Regarding the missing class label file and preview in the
.mlpackage, this can sometimes occur if the export process does not include all necessary metadata. Here is a Python example to ensure the export includes all required components:from ultralytics import YOLO # Load your trained YOLOv8 model model = YOLO("path/to/your/custom_model.pt") # Export the model to CoreML format model.export(format="coreml", nms=True) # Ensure NMS is included for proper detectionAfter exporting, you can manually check the
.mlpackageto ensure it contains the necessary class labels and preview files. If they are still missing, please let us know, and we can further investigate.For more detailed instructions on exporting to CoreML, you can visit our documentation here: CoreML Export Guide.
Feel free to share any additional details or errors you encounter. We're here to help! ๐
