qaihm-bot commited on
Commit
6c7aece
·
verified ·
1 Parent(s): a3f4344

See https://github.com/quic/ai-hub-models/releases/v0.43.0 for changelog.

Files changed (2) hide show
  1. LICENSE +2 -0
  2. README.md +258 -0
LICENSE ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ The license of the original trained model can be found at https://github.com/WongKinYiu/yolor/blob/main/LICENSE.
2
+ The license for the deployable model files (.tflite, .onnx, .dlc, .bin, etc.) can be found at https://github.com/WongKinYiu/yolor/blob/main/LICENSE.
README.md ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: pytorch
3
+ license: other
4
+ tags:
5
+ - real_time
6
+ - android
7
+ pipeline_tag: object-detection
8
+
9
+ ---
10
+
11
+ ![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/yolor/web-assets/model_demo.png)
12
+
13
+ # Yolo-R: Optimized for Mobile Deployment
14
+ ## Real-time object detection optimized for mobile and edge
15
+
16
+
17
+ YoloR is a machine learning model that predicts bounding boxes and classes of objects in an image.
18
+
19
+ This model is an implementation of Yolo-R found [here](https://github.com/WongKinYiu/yolor.git).
20
+
21
+
22
+ This repository provides scripts to run Yolo-R on Qualcomm® devices.
23
+ More details on model performance across various devices, can be found
24
+ [here](https://aihub.qualcomm.com/models/yolor).
25
+
26
+ **WARNING**: The model assets are not readily available for download due to licensing restrictions.
27
+
28
+ ### Model Details
29
+
30
+ - **Model Type:** Model_use_case.object_detection
31
+ - **Model Stats:**
32
+ - Model checkpoint: yolor_p6
33
+ - Input resolution: 640x640
34
+ - Number of parameters: 4.68M
35
+ - Model size (float): 17.9 MB
36
+
37
+ | Model | Precision | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit | Target Model
38
+ |---|---|---|---|---|---|---|---|---|
39
+ | Yolo-R | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | TFLITE | 129.679 ms | 0 - 109 MB | NPU | -- |
40
+ | Yolo-R | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | QNN_DLC | 96.176 ms | 4 - 165 MB | NPU | -- |
41
+ | Yolo-R | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | TFLITE | 77.424 ms | 0 - 141 MB | NPU | -- |
42
+ | Yolo-R | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | QNN_DLC | 58.444 ms | 5 - 116 MB | NPU | -- |
43
+ | Yolo-R | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | TFLITE | 47.158 ms | 0 - 27 MB | NPU | -- |
44
+ | Yolo-R | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | QNN_DLC | 27.084 ms | 5 - 45 MB | NPU | -- |
45
+ | Yolo-R | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | ONNX | 46.573 ms | 0 - 171 MB | NPU | -- |
46
+ | Yolo-R | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | TFLITE | 54.495 ms | 1 - 109 MB | NPU | -- |
47
+ | Yolo-R | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | QNN_DLC | 32.618 ms | 3 - 168 MB | NPU | -- |
48
+ | Yolo-R | float | SA7255P ADP | Qualcomm® SA7255P | TFLITE | 129.679 ms | 0 - 109 MB | NPU | -- |
49
+ | Yolo-R | float | SA7255P ADP | Qualcomm® SA7255P | QNN_DLC | 96.176 ms | 4 - 165 MB | NPU | -- |
50
+ | Yolo-R | float | SA8255 (Proxy) | Qualcomm® SA8255P (Proxy) | TFLITE | 48.673 ms | 0 - 32 MB | NPU | -- |
51
+ | Yolo-R | float | SA8255 (Proxy) | Qualcomm® SA8255P (Proxy) | QNN_DLC | 27.325 ms | 4 - 48 MB | NPU | -- |
52
+ | Yolo-R | float | SA8295P ADP | Qualcomm® SA8295P | TFLITE | 85.322 ms | 1 - 89 MB | NPU | -- |
53
+ | Yolo-R | float | SA8295P ADP | Qualcomm® SA8295P | QNN_DLC | 40.305 ms | 5 - 117 MB | NPU | -- |
54
+ | Yolo-R | float | SA8650 (Proxy) | Qualcomm® SA8650P (Proxy) | TFLITE | 48.864 ms | 1 - 24 MB | NPU | -- |
55
+ | Yolo-R | float | SA8650 (Proxy) | Qualcomm® SA8650P (Proxy) | QNN_DLC | 27.385 ms | 5 - 48 MB | NPU | -- |
56
+ | Yolo-R | float | SA8775P ADP | Qualcomm® SA8775P | TFLITE | 54.495 ms | 1 - 109 MB | NPU | -- |
57
+ | Yolo-R | float | SA8775P ADP | Qualcomm® SA8775P | QNN_DLC | 32.618 ms | 3 - 168 MB | NPU | -- |
58
+ | Yolo-R | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | TFLITE | 35.582 ms | 0 - 162 MB | NPU | -- |
59
+ | Yolo-R | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | QNN_DLC | 20.63 ms | 5 - 219 MB | NPU | -- |
60
+ | Yolo-R | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | ONNX | 36.224 ms | 7 - 269 MB | NPU | -- |
61
+ | Yolo-R | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | TFLITE | 32.197 ms | 1 - 112 MB | NPU | -- |
62
+ | Yolo-R | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | QNN_DLC | 16.138 ms | 5 - 151 MB | NPU | -- |
63
+ | Yolo-R | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | ONNX | 24.839 ms | 2 - 133 MB | NPU | -- |
64
+ | Yolo-R | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen5 Mobile | TFLITE | 27.294 ms | 1 - 112 MB | NPU | -- |
65
+ | Yolo-R | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen5 Mobile | QNN_DLC | 12.526 ms | 5 - 194 MB | NPU | -- |
66
+ | Yolo-R | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen5 Mobile | ONNX | 23.82 ms | 5 - 194 MB | NPU | -- |
67
+ | Yolo-R | float | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN_DLC | 26.911 ms | 100 - 100 MB | NPU | -- |
68
+ | Yolo-R | float | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 45.6 ms | 75 - 75 MB | NPU | -- |
69
+
70
+
71
+
72
+
73
+ ## Installation
74
+
75
+
76
+ Install the package via pip:
77
+ ```bash
78
+ pip install qai-hub-models
79
+ ```
80
+
81
+
82
+ ## Configure Qualcomm® AI Hub Workbench to run this model on a cloud-hosted device
83
+
84
+ Sign-in to [Qualcomm® AI Hub Workbench](https://workbench.aihub.qualcomm.com/) with your
85
+ Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.
86
+
87
+ With this API token, you can configure your client to run models on the cloud
88
+ hosted devices.
89
+ ```bash
90
+ qai-hub configure --api_token API_TOKEN
91
+ ```
92
+ Navigate to [docs](https://workbench.aihub.qualcomm.com/docs/) for more information.
93
+
94
+
95
+
96
+ ## Demo off target
97
+
98
+ The package contains a simple end-to-end demo that downloads pre-trained
99
+ weights and runs this model on a sample input.
100
+
101
+ ```bash
102
+ python -m qai_hub_models.models.yolor.demo
103
+ ```
104
+
105
+ The above demo runs a reference implementation of pre-processing, model
106
+ inference, and post processing.
107
+
108
+ **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
109
+ environment, please add the following to your cell (instead of the above).
110
+ ```
111
+ %run -m qai_hub_models.models.yolor.demo
112
+ ```
113
+
114
+
115
+ ### Run model on a cloud-hosted device
116
+
117
+ In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
118
+ device. This script does the following:
119
+ * Performance check on-device on a cloud-hosted device
120
+ * Downloads compiled assets that can be deployed on-device for Android.
121
+ * Accuracy check between PyTorch and on-device outputs.
122
+
123
+ ```bash
124
+ python -m qai_hub_models.models.yolor.export
125
+ ```
126
+
127
+
128
+
129
+ ## How does this work?
130
+
131
+ This [export script](https://aihub.qualcomm.com/models/yolor/qai_hub_models/models/Yolo-R/export.py)
132
+ leverages [Qualcomm® AI Hub](https://aihub.qualcomm.com/) to optimize, validate, and deploy this model
133
+ on-device. Lets go through each step below in detail:
134
+
135
+ Step 1: **Compile model for on-device deployment**
136
+
137
+ To compile a PyTorch model for on-device deployment, we first trace the model
138
+ in memory using the `jit.trace` and then call the `submit_compile_job` API.
139
+
140
+ ```python
141
+ import torch
142
+
143
+ import qai_hub as hub
144
+ from qai_hub_models.models.yolor import Model
145
+
146
+ # Load the model
147
+ torch_model = Model.from_pretrained()
148
+
149
+ # Device
150
+ device = hub.Device("Samsung Galaxy S25")
151
+
152
+ # Trace model
153
+ input_shape = torch_model.get_input_spec()
154
+ sample_inputs = torch_model.sample_inputs()
155
+
156
+ pt_model = torch.jit.trace(torch_model, [torch.tensor(data[0]) for _, data in sample_inputs.items()])
157
+
158
+ # Compile model on a specific device
159
+ compile_job = hub.submit_compile_job(
160
+ model=pt_model,
161
+ device=device,
162
+ input_specs=torch_model.get_input_spec(),
163
+ )
164
+
165
+ # Get target model to run on-device
166
+ target_model = compile_job.get_target_model()
167
+
168
+ ```
169
+
170
+
171
+ Step 2: **Performance profiling on cloud-hosted device**
172
+
173
+ After compiling models from step 1. Models can be profiled model on-device using the
174
+ `target_model`. Note that this scripts runs the model on a device automatically
175
+ provisioned in the cloud. Once the job is submitted, you can navigate to a
176
+ provided job URL to view a variety of on-device performance metrics.
177
+ ```python
178
+ profile_job = hub.submit_profile_job(
179
+ model=target_model,
180
+ device=device,
181
+ )
182
+
183
+ ```
184
+
185
+ Step 3: **Verify on-device accuracy**
186
+
187
+ To verify the accuracy of the model on-device, you can run on-device inference
188
+ on sample input data on the same cloud hosted device.
189
+ ```python
190
+ input_data = torch_model.sample_inputs()
191
+ inference_job = hub.submit_inference_job(
192
+ model=target_model,
193
+ device=device,
194
+ inputs=input_data,
195
+ )
196
+ on_device_output = inference_job.download_output_data()
197
+
198
+ ```
199
+ With the output of the model, you can compute like PSNR, relative errors or
200
+ spot check the output with expected output.
201
+
202
+ **Note**: This on-device profiling and inference requires access to Qualcomm®
203
+ AI Hub Workbench. [Sign up for access](https://myaccount.qualcomm.com/signup).
204
+
205
+
206
+
207
+ ## Run demo on a cloud-hosted device
208
+
209
+ You can also run the demo on-device.
210
+
211
+ ```bash
212
+ python -m qai_hub_models.models.yolor.demo --eval-mode on-device
213
+ ```
214
+
215
+ **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
216
+ environment, please add the following to your cell (instead of the above).
217
+ ```
218
+ %run -m qai_hub_models.models.yolor.demo -- --eval-mode on-device
219
+ ```
220
+
221
+
222
+ ## Deploying compiled model to Android
223
+
224
+
225
+ The models can be deployed using multiple runtimes:
226
+ - TensorFlow Lite (`.tflite` export): [This
227
+ tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
228
+ guide to deploy the .tflite model in an Android application.
229
+
230
+
231
+ - QNN (`.so` export ): This [sample
232
+ app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
233
+ provides instructions on how to use the `.so` shared library in an Android application.
234
+
235
+
236
+ ## View on Qualcomm® AI Hub
237
+ Get more details on Yolo-R's performance across various devices [here](https://aihub.qualcomm.com/models/yolor).
238
+ Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
239
+
240
+
241
+ ## License
242
+ * The license for the original implementation of Yolo-R can be found
243
+ [here](https://github.com/WongKinYiu/yolor/blob/main/LICENSE).
244
+ * The license for the compiled assets for on-device deployment can be found [here](https://github.com/WongKinYiu/yolor/blob/main/LICENSE)
245
+
246
+
247
+
248
+ ## References
249
+ * [You Only Learn One Representation: Unified Network for Multiple Tasks](https://arxiv.org/abs/2105.04206)
250
+ * [Source Model Implementation](https://github.com/WongKinYiu/yolor.git)
251
+
252
+
253
+
254
+ ## Community
255
+ * Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
256
+ * For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
257
+
258
+