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_name: pytorch
|
3 |
+
license: agpl-3.0
|
4 |
+
pipeline_tag: object-detection
|
5 |
+
tags:
|
6 |
+
- real_time
|
7 |
+
- android
|
8 |
+
|
9 |
+
---
|
10 |
+
|
11 |
+
![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/yolov11_det/web-assets/model_demo.png)
|
12 |
+
|
13 |
+
# YOLOv11-Detection: Optimized for Mobile Deployment
|
14 |
+
## Real-time object detection optimized for mobile and edge by Ultralytics
|
15 |
+
|
16 |
+
Ultralytics YOLOv11 is a machine learning model that predicts bounding boxes and classes of objects in an image.
|
17 |
+
|
18 |
+
This model is an implementation of YOLOv11-Detection found [here]({source_repo}).
|
19 |
+
This repository provides scripts to run YOLOv11-Detection on Qualcomm® devices.
|
20 |
+
More details on model performance across various devices, can be found
|
21 |
+
[here](https://aihub.qualcomm.com/models/yolov11_det).
|
22 |
+
|
23 |
+
|
24 |
+
### Model Details
|
25 |
+
|
26 |
+
- **Model Type:** Object detection
|
27 |
+
- **Model Stats:**
|
28 |
+
- Model checkpoint: YOLO11-N
|
29 |
+
- Input resolution: 640x640
|
30 |
+
- Number of parameters: None
|
31 |
+
- Model size: None
|
32 |
+
|
33 |
+
| Model | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Precision | Primary Compute Unit | Target Model
|
34 |
+
|---|---|---|---|---|---|---|---|---|
|
35 |
+
| YOLOv11-Detection | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | TFLITE | 5.441 ms | 0 - 91 MB | FP16 | NPU | [YOLOv11-Detection.tflite](https://huggingface.co/qualcomm/YOLOv11-Detection/blob/main/YOLOv11-Detection.tflite) |
|
36 |
+
| YOLOv11-Detection | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | QNN | 5.576 ms | 6 - 17 MB | FP16 | NPU | [YOLOv11-Detection.so](https://huggingface.co/qualcomm/YOLOv11-Detection/blob/main/YOLOv11-Detection.so) |
|
37 |
+
| YOLOv11-Detection | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | ONNX | 6.016 ms | 1 - 6 MB | FP16 | NPU | [YOLOv11-Detection.onnx](https://huggingface.co/qualcomm/YOLOv11-Detection/blob/main/YOLOv11-Detection.onnx) |
|
38 |
+
| YOLOv11-Detection | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | TFLITE | 3.961 ms | 0 - 97 MB | FP16 | NPU | [YOLOv11-Detection.tflite](https://huggingface.co/qualcomm/YOLOv11-Detection/blob/main/YOLOv11-Detection.tflite) |
|
39 |
+
| YOLOv11-Detection | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | QNN | 3.96 ms | 5 - 50 MB | FP16 | NPU | [YOLOv11-Detection.so](https://huggingface.co/qualcomm/YOLOv11-Detection/blob/main/YOLOv11-Detection.so) |
|
40 |
+
| YOLOv11-Detection | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | ONNX | 4.285 ms | 5 - 121 MB | FP16 | NPU | [YOLOv11-Detection.onnx](https://huggingface.co/qualcomm/YOLOv11-Detection/blob/main/YOLOv11-Detection.onnx) |
|
41 |
+
| YOLOv11-Detection | QCS8550 (Proxy) | QCS8550 Proxy | TFLITE | 5.44 ms | 0 - 3 MB | FP16 | NPU | [YOLOv11-Detection.tflite](https://huggingface.co/qualcomm/YOLOv11-Detection/blob/main/YOLOv11-Detection.tflite) |
|
42 |
+
| YOLOv11-Detection | QCS8550 (Proxy) | QCS8550 Proxy | QNN | 5.374 ms | 5 - 6 MB | FP16 | NPU | Use Export Script |
|
43 |
+
| YOLOv11-Detection | SA8255 (Proxy) | SA8255P Proxy | TFLITE | 5.435 ms | 0 - 10 MB | FP16 | NPU | [YOLOv11-Detection.tflite](https://huggingface.co/qualcomm/YOLOv11-Detection/blob/main/YOLOv11-Detection.tflite) |
|
44 |
+
| YOLOv11-Detection | SA8255 (Proxy) | SA8255P Proxy | QNN | 5.407 ms | 5 - 6 MB | FP16 | NPU | Use Export Script |
|
45 |
+
| YOLOv11-Detection | SA8775 (Proxy) | SA8775P Proxy | TFLITE | 5.518 ms | 0 - 5 MB | FP16 | NPU | [YOLOv11-Detection.tflite](https://huggingface.co/qualcomm/YOLOv11-Detection/blob/main/YOLOv11-Detection.tflite) |
|
46 |
+
| YOLOv11-Detection | SA8775 (Proxy) | SA8775P Proxy | QNN | 5.402 ms | 5 - 6 MB | FP16 | NPU | Use Export Script |
|
47 |
+
| YOLOv11-Detection | SA8650 (Proxy) | SA8650P Proxy | TFLITE | 5.531 ms | 0 - 2 MB | FP16 | NPU | [YOLOv11-Detection.tflite](https://huggingface.co/qualcomm/YOLOv11-Detection/blob/main/YOLOv11-Detection.tflite) |
|
48 |
+
| YOLOv11-Detection | SA8650 (Proxy) | SA8650P Proxy | QNN | 5.35 ms | 5 - 6 MB | FP16 | NPU | Use Export Script |
|
49 |
+
| YOLOv11-Detection | QCS8450 (Proxy) | QCS8450 Proxy | TFLITE | 9.143 ms | 0 - 91 MB | FP16 | NPU | [YOLOv11-Detection.tflite](https://huggingface.co/qualcomm/YOLOv11-Detection/blob/main/YOLOv11-Detection.tflite) |
|
50 |
+
| YOLOv11-Detection | QCS8450 (Proxy) | QCS8450 Proxy | QNN | 8.619 ms | 5 - 37 MB | FP16 | NPU | Use Export Script |
|
51 |
+
| YOLOv11-Detection | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | TFLITE | 3.848 ms | 0 - 64 MB | FP16 | NPU | [YOLOv11-Detection.tflite](https://huggingface.co/qualcomm/YOLOv11-Detection/blob/main/YOLOv11-Detection.tflite) |
|
52 |
+
| YOLOv11-Detection | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | QNN | 4.086 ms | 5 - 49 MB | FP16 | NPU | Use Export Script |
|
53 |
+
| YOLOv11-Detection | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | ONNX | 3.299 ms | 0 - 74 MB | FP16 | NPU | [YOLOv11-Detection.onnx](https://huggingface.co/qualcomm/YOLOv11-Detection/blob/main/YOLOv11-Detection.onnx) |
|
54 |
+
| YOLOv11-Detection | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN | 5.7 ms | 5 - 5 MB | FP16 | NPU | Use Export Script |
|
55 |
+
| YOLOv11-Detection | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 6.775 ms | 5 - 5 MB | FP16 | NPU | [YOLOv11-Detection.onnx](https://huggingface.co/qualcomm/YOLOv11-Detection/blob/main/YOLOv11-Detection.onnx) |
|
56 |
+
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
+
## Installation
|
61 |
+
|
62 |
+
This model can be installed as a Python package via pip.
|
63 |
+
|
64 |
+
```bash
|
65 |
+
pip install "qai-hub-models[yolov11_det]"
|
66 |
+
```
|
67 |
+
|
68 |
+
|
69 |
+
|
70 |
+
## Configure Qualcomm® AI Hub to run this model on a cloud-hosted device
|
71 |
+
|
72 |
+
Sign-in to [Qualcomm® AI Hub](https://app.aihub.qualcomm.com/) with your
|
73 |
+
Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.
|
74 |
+
|
75 |
+
With this API token, you can configure your client to run models on the cloud
|
76 |
+
hosted devices.
|
77 |
+
```bash
|
78 |
+
qai-hub configure --api_token API_TOKEN
|
79 |
+
```
|
80 |
+
Navigate to [docs](https://app.aihub.qualcomm.com/docs/) for more information.
|
81 |
+
|
82 |
+
|
83 |
+
|
84 |
+
## Demo off target
|
85 |
+
|
86 |
+
The package contains a simple end-to-end demo that downloads pre-trained
|
87 |
+
weights and runs this model on a sample input.
|
88 |
+
|
89 |
+
```bash
|
90 |
+
python -m qai_hub_models.models.yolov11_det.demo
|
91 |
+
```
|
92 |
+
|
93 |
+
The above demo runs a reference implementation of pre-processing, model
|
94 |
+
inference, and post processing.
|
95 |
+
|
96 |
+
**NOTE**: If you want running in a Jupyter Notebook or Google Colab like
|
97 |
+
environment, please add the following to your cell (instead of the above).
|
98 |
+
```
|
99 |
+
%run -m qai_hub_models.models.yolov11_det.demo
|
100 |
+
```
|
101 |
+
|
102 |
+
|
103 |
+
### Run model on a cloud-hosted device
|
104 |
+
|
105 |
+
In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
|
106 |
+
device. This script does the following:
|
107 |
+
* Performance check on-device on a cloud-hosted device
|
108 |
+
* Downloads compiled assets that can be deployed on-device for Android.
|
109 |
+
* Accuracy check between PyTorch and on-device outputs.
|
110 |
+
|
111 |
+
```bash
|
112 |
+
python -m qai_hub_models.models.yolov11_det.export
|
113 |
+
```
|
114 |
+
```
|
115 |
+
Profiling Results
|
116 |
+
------------------------------------------------------------
|
117 |
+
YOLOv11-Detection
|
118 |
+
Device : Samsung Galaxy S23 (13)
|
119 |
+
Runtime : TFLITE
|
120 |
+
Estimated inference time (ms) : 5.4
|
121 |
+
Estimated peak memory usage (MB): [0, 91]
|
122 |
+
Total # Ops : 382
|
123 |
+
Compute Unit(s) : NPU (382 ops)
|
124 |
+
```
|
125 |
+
|
126 |
+
|
127 |
+
## How does this work?
|
128 |
+
|
129 |
+
This [export script](https://aihub.qualcomm.com/models/yolov11_det/qai_hub_models/models/YOLOv11-Detection/export.py)
|
130 |
+
leverages [Qualcomm® AI Hub](https://aihub.qualcomm.com/) to optimize, validate, and deploy this model
|
131 |
+
on-device. Lets go through each step below in detail:
|
132 |
+
|
133 |
+
Step 1: **Compile model for on-device deployment**
|
134 |
+
|
135 |
+
To compile a PyTorch model for on-device deployment, we first trace the model
|
136 |
+
in memory using the `jit.trace` and then call the `submit_compile_job` API.
|
137 |
+
|
138 |
+
```python
|
139 |
+
import torch
|
140 |
+
|
141 |
+
import qai_hub as hub
|
142 |
+
from qai_hub_models.models.yolov11_det import
|
143 |
+
|
144 |
+
# Load the model
|
145 |
+
|
146 |
+
# Device
|
147 |
+
device = hub.Device("Samsung Galaxy S23")
|
148 |
+
|
149 |
+
|
150 |
+
```
|
151 |
+
|
152 |
+
|
153 |
+
Step 2: **Performance profiling on cloud-hosted device**
|
154 |
+
|
155 |
+
After compiling models from step 1. Models can be profiled model on-device using the
|
156 |
+
`target_model`. Note that this scripts runs the model on a device automatically
|
157 |
+
provisioned in the cloud. Once the job is submitted, you can navigate to a
|
158 |
+
provided job URL to view a variety of on-device performance metrics.
|
159 |
+
```python
|
160 |
+
profile_job = hub.submit_profile_job(
|
161 |
+
model=target_model,
|
162 |
+
device=device,
|
163 |
+
)
|
164 |
+
|
165 |
+
```
|
166 |
+
|
167 |
+
Step 3: **Verify on-device accuracy**
|
168 |
+
|
169 |
+
To verify the accuracy of the model on-device, you can run on-device inference
|
170 |
+
on sample input data on the same cloud hosted device.
|
171 |
+
```python
|
172 |
+
input_data = torch_model.sample_inputs()
|
173 |
+
inference_job = hub.submit_inference_job(
|
174 |
+
model=target_model,
|
175 |
+
device=device,
|
176 |
+
inputs=input_data,
|
177 |
+
)
|
178 |
+
on_device_output = inference_job.download_output_data()
|
179 |
+
|
180 |
+
```
|
181 |
+
With the output of the model, you can compute like PSNR, relative errors or
|
182 |
+
spot check the output with expected output.
|
183 |
+
|
184 |
+
**Note**: This on-device profiling and inference requires access to Qualcomm®
|
185 |
+
AI Hub. [Sign up for access](https://myaccount.qualcomm.com/signup).
|
186 |
+
|
187 |
+
|
188 |
+
|
189 |
+
## Run demo on a cloud-hosted device
|
190 |
+
|
191 |
+
You can also run the demo on-device.
|
192 |
+
|
193 |
+
```bash
|
194 |
+
python -m qai_hub_models.models.yolov11_det.demo --on-device
|
195 |
+
```
|
196 |
+
|
197 |
+
**NOTE**: If you want running in a Jupyter Notebook or Google Colab like
|
198 |
+
environment, please add the following to your cell (instead of the above).
|
199 |
+
```
|
200 |
+
%run -m qai_hub_models.models.yolov11_det.demo -- --on-device
|
201 |
+
```
|
202 |
+
|
203 |
+
|
204 |
+
## Deploying compiled model to Android
|
205 |
+
|
206 |
+
|
207 |
+
The models can be deployed using multiple runtimes:
|
208 |
+
- TensorFlow Lite (`.tflite` export): [This
|
209 |
+
tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
|
210 |
+
guide to deploy the .tflite model in an Android application.
|
211 |
+
|
212 |
+
|
213 |
+
- QNN (`.so` export ): This [sample
|
214 |
+
app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
|
215 |
+
provides instructions on how to use the `.so` shared library in an Android application.
|
216 |
+
|
217 |
+
|
218 |
+
## View on Qualcomm® AI Hub
|
219 |
+
Get more details on YOLOv11-Detection's performance across various devices [here](https://aihub.qualcomm.com/models/yolov11_det).
|
220 |
+
Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
|
221 |
+
|
222 |
+
|
223 |
+
## License
|
224 |
+
* The license for the original implementation of YOLOv11-Detection can be found [here](https://github.com/ultralytics/ultralytics/blob/main/LICENSE).
|
225 |
+
* The license for the compiled assets for on-device deployment can be found [here](https://github.com/ultralytics/ultralytics/blob/main/LICENSE)
|
226 |
+
|
227 |
+
|
228 |
+
|
229 |
+
## References
|
230 |
+
* [Ultralytics YOLOv11 Docs: Object Detection](https://docs.ultralytics.com/tasks/detect/)
|
231 |
+
* [Source Model Implementation](https://github.com/ultralytics/ultralytics/tree/main/ultralytics/models/yolo/detect)
|
232 |
+
|
233 |
+
|
234 |
+
|
235 |
+
## Community
|
236 |
+
* Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
|
237 |
+
* For questions or feedback please [reach out to us](mailto:[email protected]).
|
238 |
+
|
239 |
+
|