Loading repository data…
Loading repository data…
ultralytics / repository
Flutter plugin for Ultralytics YOLO
Ultralytics YOLO Flutter is the official plugin for running YOLO models in Flutter apps on iOS and Android. It supports detection, instance segmentation, semantic segmentation, depth estimation, classification, pose, and OBB on both platforms, with two simple entry points:
YOLO for single-image inferenceYOLOView for real-time camera inferenceThe main goal is simple integration: use an official model ID, or drop in your own exported model and let the plugin resolve task metadata for you.
| Feature | Android | iOS | Details |
|---|---|---|---|
| Object Detection | ✅ | ✅ | Bounding boxes, labels, and confidence scores |
| Instance Segmentation | ✅ | ✅ | Instance masks with boxes and classes |
| Semantic Segmentation | ✅ | ✅ | Dense class masks for every pixel |
| Monocular Depth Estimation | ✅ | ✅ | Official LiteRT and Core ML models |
| Image Classification | ✅ | ✅ | Top class predictions and scores |
| Pose Estimation | ✅ | ✅ | Keypoints with boxes and confidence scores |
| Oriented Bounding Box (OBB) Detection | ✅ | ✅ | Rotated boxes and polygon corners |
| Real-Time Camera Inference | ✅ | ✅ | YOLOView for live camera workflows |
| Single-Image Inference | ✅ | ✅ | YOLO for image bytes |
| Official Models | ✅ | ✅ | Discovery, download, and caching for packaged model IDs |
| Custom Models | ✅ | ✅ | LiteRT (TFLite) on Android, Core ML on iOS, metadata-first tasks |
| Qualcomm NPU (QNN) | ✅ | — | Opt-in Hexagon NPU inference for *_qnn.onnx models on Snapdragon |
Install the package:
Package: https://pub.dev/packages/ultralytics_yolo
dependencies:
ultralytics_yolo: ^0.6.10
flutter pub get
Start with the default official model:
import 'package:ultralytics_yolo/ultralytics_yolo.dart';
final modelId = YOLO.defaultOfficialModel() ?? 'yolo26n';
YOLOView(
modelPath: modelId,
onResult: (results) {
for (final r in results) {
debugPrint('${r.className}: ${r.confidence}');
}
},
)
For single-image inference:
final yolo = YOLO(modelPath: 'yolo26n');
await yolo.loadModel();
final results = await yolo.predict(imageBytes);
▶️ Example App | 📖 Installation Guide | ⚡ Quick Start Guide
The plugin supports three model flows.
Use the default official model or a specific official ID and let the plugin handle download and caching:
final yolo = YOLO(modelPath: YOLO.defaultOfficialModel() ?? 'yolo26n');
Call YOLO.officialModels() to see which official IDs are available on the current platform. Official assets are downloaded on first use and cached in app storage, so the app package does not carry large model files.
Official assets are maintained as GitHub release assets:
| Platform | Runtime asset | Release |
|---|---|---|
| Android | LiteRT w8a32 .tflite | yolo-flutter-app v0.6.6 |
| Android NPU (opt-in) | QNN *_v73/_v81_qnn.onnx | yolo-flutter-app v0.3.5 |
| iOS | Core ML int8 .mlpackage.zip | yolo-ios-app v8.3.0 |
The Flutter resolver uses the TFLite release for Android and the Core ML release for Apple platforms. These release tags are intentionally pinned for reproducible first-use downloads. See the model guide for the official export matrix, URL patterns, and model properties.
Pass your own exported YOLO model as a local path or Flutter asset path:
final yolo = YOLO(modelPath: 'assets/models/my-finetuned-model.tflite');
If the exported model includes embedded metadata, the plugin infers task and class labels automatically — it reads Ultralytics' appended-ZIP metadata, with a standard TFLite (FlatBuffers) metadata fallback — so drag-and-drop custom models auto-detect. If metadata is missing, pass task explicitly.
final yolo = YOLO(
modelPath: 'assets/models/my-finetuned-model.tflite',
task: YOLOTask.detect,
);
Pass an http or https URL and the plugin will download it into app storage before loading it.
Android ships with LiteRT (TFLite) and that remains the default — nothing changes for existing apps, and the
QNN support adds zero bytes to your build. Any model path ending in _qnn.onnx (a Qualcomm QNN context binary
exported with yolo export format=qnn) is routed to the Hexagon NPU through the ONNX Runtime QNN Execution
Provider instead.
Running QNN models requires a Snapdragon device with a Hexagon HTP (Snapdragon 8 Gen 2 or newer for the official
_v73 assets; _v81 targets Snapdragon 8 Elite Gen 5) and three additions to your app's
android/app/build.gradle:
android {
packagingOptions {
jniLibs {
useLegacyPackaging = true // the Hexagon DSP loader needs real .so files, not APK-mmapped ones
}
}
}
dependencies {
implementation 'com.microsoft.onnxruntime:onnxruntime-android-qnn:1.26.0'
implementation 'com.qualcomm.qti:qnn-runtime:2.46.0' // newer than the AAR's bundled QAIRT; required for the latest Snapdragons
}
final yolo = YOLO(
modelPath: 'https://github.com/ultralytics/yolo-flutter-app/releases/download/v0.3.5/yolo26n_v73_qnn.onnx',
task: YOLOTask.detect,
);
Without the Gradle opt-in, loading a _qnn.onnx model fails with a clear error and TFLite models are unaffected. The bundled example app follows the same opt-in — it ships without the QNN runtime to keep its download small, so build it with ENABLE_QNN=1 (e.g. ENABLE_QNN=1 flutter run --release) to test the NPU path on a device.
See the performance guide for measured CPU/GPU/NPU numbers and tuning notes.
| Use case | Recommended path |
|---|---|
| Fastest first integration | Official model ID like yolo26n |
| You trained or exported your own model | Custom asset or local file |
| You ship different models per customer or environment | Remote URL |
You need the plugin to infer task automatically | Any export with metadata |
| You have an older or stripped export without metadata | Custom model plus explicit task |
For official models, start with YOLO.defaultOfficialModel() or YOLO.officialModels(). For custom models, start with the exported file you actually plan to ship.
For custom models, keep the app-side setup minimal.
.tflite files in android/app/src/main/assets.tflite files in assets/models/.mlpackage or .mlmodel into ios/Runner.xcworkspace.mlpackage.zip files in assets/models/Then point modelPath at that file or asset path.
The Android TFLite release assets are generated by scripts/export-tflite-models.py. The script defines the official YOLO26 task/size matrix, w8a32 export settings (int8 weights, FP32 activations — dynamic-range, so no calibration data is needed), optional one-shot TFLite inference verification, and optional GitHub release upload.
Run it on Linux x86 or macOS with Python ≥3.10:
uv venv --python 3.12 .venv
uv pip install --index-url https://download.pytorch.org/whl/cpu torch torchvision
uv pip install "ultralytics-opencv-headless[export-litert]>=8.4.83"
uv run python scripts/export-tflite-models.py --verify
Use `--upload --repo ultralytics/yolo-flutter