Skip to content

Commit f9d7b82

Browse files
Unify Flutter model resolution around metadata (#469)
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
1 parent 8deb7cc commit f9d7b82

43 files changed

Lines changed: 2010 additions & 4310 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
## Unreleased
2+
3+
- **Feature**: Add package-level model resolution for official IDs, remote URLs, local files, and Flutter assets.
4+
- **Enhancement**: Resolve `task` from exported metadata when available across `YOLO`, `YOLOView`, and `YOLOViewController.switchModel()`.
5+
- **Enhancement**: Replace hardcoded release URL assumptions with an official model catalog and latest-release resolution.
6+
- **Cleanup**: Remove example-only model management duplication and update docs around the metadata-first flow.
7+
18
## 0.2.0
29

310
- **Feature**: YOLO26 model release — `yolo26*` CoreML (`.mlpackage`) and TFLite (`.tflite`) artifacts published alongside YOLOv11 (#431, #432).
411
- **Enhancement**: YOLO property and method surface updates (#428).
512
- Documentation update for model downloads:
6-
- All model download links point to GitHub release `v0.2.0` (no bundled models).
13+
- Official models are hosted as GitHub release assets rather than bundled in the package.
714
- Added YOLO26 references alongside YOLOv11 for both CoreML (`.mlpackage`) and TFLite (`.tflite`) artifacts.
815
- Clarified that models are pulled from release assets rather than packaged in the app.
916

README.md

Lines changed: 113 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@
1212
[![Ultralytics Forums](https://img.shields.io/discourse/users?server=https%3A%2F%2Fcommunity.ultralytics.com&logo=discourse&label=Forums&color=blue)](https://community.ultralytics.com/)
1313
[![Ultralytics Reddit](https://img.shields.io/reddit/subreddit-subscribers/ultralytics?style=flat&logo=reddit&logoColor=white&label=Reddit&color=blue)](https://www.reddit.com/r/ultralytics/)
1414

15-
Welcome to the Ultralytics YOLO Flutter plugin! Integrate cutting-edge [Ultralytics YOLO](https://docs.ultralytics.com/) [computer vision](https://www.ultralytics.com/glossary/computer-vision-cv) models seamlessly into your Flutter mobile applications. This plugin at https://pub.dev/packages/ultralytics_yolo supports both Android and iOS platforms, offering APIs for [object detection](https://docs.ultralytics.com/tasks/detect/), [image classification](https://docs.ultralytics.com/tasks/classify/), [instance segmentation](https://docs.ultralytics.com/tasks/segment/), [pose estimation](https://docs.ultralytics.com/tasks/pose/), and [oriented bounding box detection](https://docs.ultralytics.com/tasks/obb/).
15+
Ultralytics YOLO Flutter is the official plugin for running YOLO models in Flutter apps on iOS and Android. It supports [detection](https://docs.ultralytics.com/tasks/detect/), [segmentation](https://docs.ultralytics.com/tasks/segment/), [classification](https://docs.ultralytics.com/tasks/classify/), [pose](https://docs.ultralytics.com/tasks/pose/), and [OBB](https://docs.ultralytics.com/tasks/obb/) with two simple entry points:
1616

17-
**✨ Why Choose YOLO Flutter?**
17+
- `YOLO` for single-image inference
18+
- `YOLOView` for real-time camera inference
19+
20+
The 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.
21+
22+
## ✨ Why This Plugin
1823

1924
| Feature | Android | iOS |
2025
| --------------- | ------- | --- |
@@ -24,114 +29,159 @@ Welcome to the Ultralytics YOLO Flutter plugin! Integrate cutting-edge [Ultralyt
2429
| Pose Estimation |||
2530
| OBB Detection |||
2631

27-
- **Official Ultralytics Plugin** - Direct from YOLO creators
28-
- **Real-time Performance** - Up to 30 FPS on modern devices
29-
- **5 AI Tasks** - Detection, Segmentation, Classification, Pose, OBB
30-
- **Cross-platform** - iOS & Android with single codebase
31-
- **Production Ready** - Performance controls & optimization built-in
32-
- **Dynamic Model Loading** - Switch models on-the-fly without restarting camera
33-
- **Frame Capture** - Capture frames with detection overlays for sharing or saving
32+
- Official Ultralytics plugin
33+
- One Flutter API for both Android and iOS
34+
- Metadata-first model loading
35+
- Official model download and caching built in
36+
- Real-time camera inference and single-image inference
37+
- Production-ready controls for thresholds, GPU use, and streaming
38+
39+
## ⚡ Quick Start
3440

35-
## ⚡ Quick Start (2 minutes)
41+
Install the package:
42+
43+
```yaml
44+
dependencies:
45+
ultralytics_yolo: ^0.2.0
46+
```
47+
48+
```bash
49+
flutter pub get
50+
```
51+
52+
Start with the default official model:
3653

3754
```dart
3855
import 'package:ultralytics_yolo/ultralytics_yolo.dart';
3956
40-
// Add this widget and you're detecting objects!
4157
YOLOView(
42-
modelPath: 'yolo11n',
43-
task: YOLOTask.detect,
58+
modelPath: 'yolo26n',
4459
onResult: (results) {
45-
print('Found ${results.length} objects!');
4660
for (final result in results) {
4761
print('${result.className}: ${result.confidence}');
4862
}
4963
},
5064
)
5165
```
5266

53-
**[▶️ Try the Live Demo](./example)** | **[📖 Full Setup Guide](doc/install.md)**
67+
For single-image inference:
5468

55-
## 🎯 What You Can Build
69+
```dart
70+
final yolo = YOLO(modelPath: 'yolo26n');
71+
await yolo.loadModel();
72+
final results = await yolo.predict(imageBytes);
73+
```
5674

57-
| Task | Description | Use Cases | Performance |
58-
| ------------------- | ------------------------------ | ----------------------------- | ----------- |
59-
| **Detection** | Find objects & their locations | Security, Inventory, Shopping | 25-30 FPS |
60-
| **Segmentation** | Pixel-perfect object masks | Photo editing | 15-25 FPS |
61-
| **Classification** | Identify image categories | Content moderation, Tagging | 30+ FPS |
62-
| **Pose Estimation** | Human pose & keypoints | Fitness apps, Motion capture | 20-30 FPS |
63-
| **OBB Detection** | Rotated bounding boxes | Aerial imagery | 20-25 FPS |
75+
**[▶️ Example App](./example)** | **[📖 Installation Guide](doc/install.md)** | **[⚡ Quick Start Guide](doc/quickstart.md)**
6476

65-
**[📱 See Examples →](doc/usage.md)** | **[⚡ Performance Guide →](doc/performance.md)**
77+
## 📦 Model Loading
6678

67-
## 🚀 Installation
79+
The plugin supports three model flows.
6880

69-
### 1. Add to pubspec.yaml
81+
### 1. Official model IDs
7082

71-
```yaml
72-
dependencies:
73-
ultralytics_yolo: ^0.2.0
83+
Use an official ID such as `yolo26n` and let the plugin handle download and caching:
84+
85+
```dart
86+
final yolo = YOLO(modelPath: 'yolo26n');
7487
```
7588

76-
### 2. Install dependencies
89+
Call `YOLO.officialModels()` to see which official IDs are available on the current platform.
7790

78-
```bash
79-
flutter pub get
91+
### 2. Your own exported model
92+
93+
Pass a local path or Flutter asset path:
94+
95+
```dart
96+
final yolo = YOLO(modelPath: 'assets/models/custom.tflite');
8097
```
8198

82-
### 3. Add a model
99+
If the exported model includes metadata, the plugin infers `task` automatically. If metadata is missing, pass `task` explicitly.
100+
101+
### 3. Remote model URL
102+
103+
Pass an `http` or `https` URL and the plugin will download it into app storage before loading it.
104+
105+
## 🧭 Official Vs Custom
83106

84-
You can get the model in one of the following ways:
107+
| Use case | Recommended path |
108+
| ----------------------------------------------------- | --------------------------------- |
109+
| Fastest first integration | Official model ID like `yolo26n` |
110+
| You trained or exported your own model | Custom asset or local file |
111+
| You ship different models per customer or environment | Remote URL |
112+
| You need the plugin to infer `task` automatically | Any export with metadata |
113+
| You have an older or stripped export without metadata | Custom model plus explicit `task` |
85114

86-
1. Download from the [release assets](https://github.com/ultralytics/yolo-flutter-app/releases/tag/v0.2.0) of this repository
115+
For official models, start with `YOLO.officialModels()`. For custom models, start with the exported file you actually plan to ship.
87116

88-
2. Get it from [Ultralytics HUB](https://www.ultralytics.com/hub)
117+
## 📥 Drop Your Own Model Into an App
89118

90-
3. Export it from [Ultralytics/ultralytics](https://github.com/ultralytics/ultralytics) ([CoreML](https://docs.ultralytics.com/integrations/coreml/)/[TFLite](https://docs.ultralytics.com/integrations/tflite/))
119+
For custom models, keep the app-side setup minimal.
91120

92-
For YOLO26, use the same steps and grab the `yolo26*` artifacts from the `v0.2.0` release (e.g., `yolo26n.tflite` / `yolo26n.mlpackage`).
121+
- Android native assets: place `.tflite` files in `android/app/src/main/assets`
122+
- Flutter assets on Android: place `.tflite` files in `assets/models/`
123+
- iOS bundle: drag `.mlpackage` or `.mlmodel` into `ios/Runner.xcworkspace`
124+
- Flutter assets on iOS: place `.mlpackage.zip` files in `assets/models/`
93125

94-
### Export Models for iOS
126+
Then point `modelPath` at that file or asset path.
127+
128+
### iOS export note
129+
130+
Detection models exported to CoreML must use `nms=True`:
95131

96132
```python
97-
# Detection REQUIRES nms=True
98-
YOLO("yolo11n.pt").export(format="coreml", nms=True)
133+
from ultralytics import YOLO
99134

100-
# All other tasks use nms=False (default)
101-
YOLO("yolo11n-seg.pt").export(format="coreml")
135+
YOLO("yolo26n.pt").export(format="coreml", nms=True)
102136
```
103137

104-
**[📥 Download Models](doc/models.md)**
138+
Other tasks can use the default export settings.
105139

106-
Bundle the model with your app using the following method.
140+
## 🎯 Choose The Right API
107141

108-
For iOS: Drag and drop mlpackage/mlmodel directly into **ios/Runner.xcworkspace** and set target to Runner.
142+
Use `YOLO` when you already have image bytes and want one prediction at a time:
109143

110-
For Android: Create a folder called **android/app/src/main/assets** and place tflite files in it.
144+
```dart
145+
final yolo = YOLO(modelPath: 'yolo26n');
146+
await yolo.loadModel();
147+
final results = await yolo.predict(imageBytes);
148+
```
111149

112-
### 4. Platform-Specific Setup
150+
Use `YOLOView` when you want live camera inference:
113151

114-
**[🔧 Setup Guide](doc/install.md)**
152+
```dart
153+
final controller = YOLOViewController();
115154
116-
## 🏆 Trusted by Developers
155+
YOLOView(
156+
modelPath: 'yolo26n',
157+
controller: controller,
158+
onResult: (results) {},
159+
)
160+
161+
await controller.switchModel('assets/models/custom.tflite', YOLOTask.detect);
162+
```
117163

118-
-**Official Ultralytics Plugin** - Maintained by YOLO creators
119-
-**Production Tested** - Used in apps with many users
120-
-**Active Development** - Regular updates & feature additions
121-
-**Community Driven** - Open source with responsive support
164+
## 🧩 Recommended Patterns
122165

123-
**Performance**: Up to 30 FPS on modern devices | **Model Size**: Optimized from 6MB | **Platforms**: iOS 13.0+ & Android API 21+
166+
| App type | Model loading pattern |
167+
| ---------------------------------- | ---------------------------------------------------------------------- |
168+
| Live camera app | `YOLOView(modelPath: 'yolo26n')` |
169+
| Photo picker or gallery workflow | `YOLO(modelPath: 'yolo26n')` |
170+
| App with your own bundled model | `YOLO(modelPath: 'assets/models/custom.tflite')` |
171+
| Cross-platform CoreML + TFLite app | Use platform-appropriate exported assets and let metadata drive `task` |
172+
| App that changes models at runtime | `YOLOViewController.switchModel(...)` |
124173

125174
## 📚 Documentation
126175

127-
| Guide | Description | For |
128-
| -------------------------------------------------- | --------------------------------- | --------------- |
129-
| **[Installation Guide](doc/install.md)** | Installation, setup, requirements | New users |
130-
| **[Quick Start](doc/quickstart.md)** | 2-minute setup guide | New users |
131-
| **[Usage Guide](doc/usage.md)** | Common use cases & code samples | All users |
132-
| **[Performance Optimization](doc/performance.md)** | Inference control & tuning | Production apps |
133-
| **[API Reference](doc/api.md)** | Complete technical reference | Developers |
134-
| **[Troubleshooting](doc/troubleshooting.md)** | Common issues & solutions | All users |
176+
| Guide | Description |
177+
| --------------------------------------------- | ------------------------------------------- |
178+
| **[Installation Guide](doc/install.md)** | Requirements and platform setup |
179+
| **[Quick Start](doc/quickstart.md)** | Minimal setup for the first working app |
180+
| **[Model Guide](doc/models.md)** | Official models, custom models, export flow |
181+
| **[Usage Guide](doc/usage.md)** | Common app patterns and examples |
182+
| **[API Reference](doc/api.md)** | Full API surface |
183+
| **[Performance Guide](doc/performance.md)** | Tuning and performance controls |
184+
| **[Troubleshooting](doc/troubleshooting.md)** | Common problems and fixes |
135185

136186
## 🤝 Community & Support
137187

0 commit comments

Comments
 (0)