qaihm-bot commited on
Commit
44530e7
·
verified ·
1 Parent(s): 00d3d20

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

Files changed (1) hide show
  1. README.md +191 -38
README.md CHANGED
@@ -19,7 +19,11 @@ RTMDet is a highly efficient model for real-time object detection,capable of pre
19
  This model is an implementation of RTMDet found [here](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/rtmdet).
20
 
21
 
22
- More details on model performance across various devices, can be found [here](https://aihub.qualcomm.com/models/rtmdet).
 
 
 
 
23
 
24
  ### Model Details
25
 
@@ -32,24 +36,192 @@ This model is an implementation of RTMDet found [here](https://github.com/open-m
32
 
33
  | Model | Precision | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit | Target Model
34
  |---|---|---|---|---|---|---|---|---|
35
- | RTMDet | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | TFLITE | 85.266 ms | 0 - 63 MB | NPU | -- |
36
- | RTMDet | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | TFLITE | 32.519 ms | 0 - 111 MB | NPU | -- |
37
- | RTMDet | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | TFLITE | 15.695 ms | 0 - 17 MB | NPU | -- |
38
- | RTMDet | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | TFLITE | 23.681 ms | 0 - 63 MB | NPU | -- |
39
- | RTMDet | float | SA7255P ADP | Qualcomm® SA7255P | TFLITE | 85.266 ms | 0 - 63 MB | NPU | -- |
40
- | RTMDet | float | SA8255 (Proxy) | Qualcomm® SA8255P (Proxy) | TFLITE | 16.077 ms | 0 - 14 MB | NPU | -- |
41
- | RTMDet | float | SA8295P ADP | Qualcomm® SA8295P | TFLITE | 35.604 ms | 0 - 73 MB | NPU | -- |
42
- | RTMDet | float | SA8650 (Proxy) | Qualcomm® SA8650P (Proxy) | TFLITE | 16.216 ms | 0 - 13 MB | NPU | -- |
43
- | RTMDet | float | SA8775P ADP | Qualcomm® SA8775P | TFLITE | 23.681 ms | 0 - 63 MB | NPU | -- |
44
- | RTMDet | float | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | TFLITE | 16.224 ms | 0 - 14 MB | NPU | -- |
45
- | RTMDet | float | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | ONNX | 14.484 ms | 1 - 141 MB | NPU | -- |
46
- | RTMDet | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | TFLITE | 12.277 ms | 0 - 102 MB | NPU | -- |
47
- | RTMDet | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | ONNX | 11.001 ms | 4 - 50 MB | NPU | -- |
48
- | RTMDet | float | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | TFLITE | 11.391 ms | 0 - 69 MB | NPU | -- |
49
- | RTMDet | float | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | ONNX | 10.193 ms | 7 - 47 MB | NPU | -- |
50
- | RTMDet | float | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 15.801 ms | 51 - 51 MB | NPU | -- |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
 
 
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
 
55
  ## License
@@ -66,26 +238,7 @@ This model is an implementation of RTMDet found [here](https://github.com/open-m
66
 
67
 
68
  ## Community
69
- * Join [our AI Hub Slack community](https://qualcomm-ai-hub.slack.com/join/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA#/shared-invite/email) to collaborate, post questions and learn more about on-device AI.
70
  * For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
71
 
72
- ## Usage and Limitations
73
-
74
- Model may not be used for or in connection with any of the following applications:
75
-
76
- - Accessing essential private and public services and benefits;
77
- - Administration of justice and democratic processes;
78
- - Assessing or recognizing the emotional state of a person;
79
- - Biometric and biometrics-based systems, including categorization of persons based on sensitive characteristics;
80
- - Education and vocational training;
81
- - Employment and workers management;
82
- - Exploitation of the vulnerabilities of persons resulting in harmful behavior;
83
- - General purpose social scoring;
84
- - Law enforcement;
85
- - Management and operation of critical infrastructure;
86
- - Migration, asylum and border control management;
87
- - Predictive policing;
88
- - Real-time remote biometric identification in public spaces;
89
- - Recommender systems of social media platforms;
90
- - Scraping of facial images (from the internet or otherwise); and/or
91
- - Subliminal manipulation
 
19
  This model is an implementation of RTMDet found [here](https://github.com/open-mmlab/mmdetection/tree/3.x/configs/rtmdet).
20
 
21
 
22
+ This repository provides scripts to run RTMDet on Qualcomm® devices.
23
+ More details on model performance across various devices, can be found
24
+ [here](https://aihub.qualcomm.com/models/rtmdet).
25
+
26
+ **WARNING**: The model assets are not readily available for download due to licensing restrictions.
27
 
28
  ### Model Details
29
 
 
36
 
37
  | Model | Precision | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit | Target Model
38
  |---|---|---|---|---|---|---|---|---|
39
+ | RTMDet | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | TFLITE | 85.329 ms | 0 - 63 MB | NPU | -- |
40
+ | RTMDet | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | TFLITE | 33.757 ms | 0 - 110 MB | NPU | -- |
41
+ | RTMDet | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | TFLITE | 16.091 ms | 0 - 16 MB | NPU | -- |
42
+ | RTMDet | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | TFLITE | 23.686 ms | 0 - 63 MB | NPU | -- |
43
+ | RTMDet | float | SA7255P ADP | Qualcomm® SA7255P | TFLITE | 85.329 ms | 0 - 63 MB | NPU | -- |
44
+ | RTMDet | float | SA8255 (Proxy) | Qualcomm® SA8255P (Proxy) | TFLITE | 16.11 ms | 0 - 13 MB | NPU | -- |
45
+ | RTMDet | float | SA8295P ADP | Qualcomm® SA8295P | TFLITE | 35.598 ms | 0 - 74 MB | NPU | -- |
46
+ | RTMDet | float | SA8650 (Proxy) | Qualcomm® SA8650P (Proxy) | TFLITE | 16.014 ms | 0 - 14 MB | NPU | -- |
47
+ | RTMDet | float | SA8775P ADP | Qualcomm® SA8775P | TFLITE | 23.686 ms | 0 - 63 MB | NPU | -- |
48
+ | RTMDet | float | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | TFLITE | 16.126 ms | 0 - 16 MB | NPU | -- |
49
+ | RTMDet | float | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | ONNX | 14.513 ms | 5 - 16 MB | NPU | -- |
50
+ | RTMDet | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | TFLITE | 12.298 ms | 0 - 104 MB | NPU | -- |
51
+ | RTMDet | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | ONNX | 10.944 ms | 2 - 48 MB | NPU | -- |
52
+ | RTMDet | float | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | TFLITE | 11.38 ms | 0 - 68 MB | NPU | -- |
53
+ | RTMDet | float | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | ONNX | 8.73 ms | 5 - 44 MB | NPU | -- |
54
+ | RTMDet | float | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 15.953 ms | 51 - 51 MB | NPU | -- |
55
+
56
+
57
+
58
+
59
+ ## Installation
60
+
61
+
62
+ Install the package via pip:
63
+ ```bash
64
+ pip install "qai-hub-models[rtmdet]" torch==2.4.1 -f https://download.openmmlab.com/mmcv/dist/cpu/torch2.4/index.html -f https://qaihub-public-python-wheels.s3.us-west-2.amazonaws.com/index.html
65
+ ```
66
+
67
+
68
+ ## Configure Qualcomm® AI Hub to run this model on a cloud-hosted device
69
+
70
+ Sign-in to [Qualcomm® AI Hub](https://app.aihub.qualcomm.com/) with your
71
+ Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.
72
+
73
+ With this API token, you can configure your client to run models on the cloud
74
+ hosted devices.
75
+ ```bash
76
+ qai-hub configure --api_token API_TOKEN
77
+ ```
78
+ Navigate to [docs](https://app.aihub.qualcomm.com/docs/) for more information.
79
+
80
+
81
+
82
+ ## Demo off target
83
+
84
+ The package contains a simple end-to-end demo that downloads pre-trained
85
+ weights and runs this model on a sample input.
86
+
87
+ ```bash
88
+ python -m qai_hub_models.models.rtmdet.demo
89
+ ```
90
+
91
+ The above demo runs a reference implementation of pre-processing, model
92
+ inference, and post processing.
93
+
94
+ **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
95
+ environment, please add the following to your cell (instead of the above).
96
+ ```
97
+ %run -m qai_hub_models.models.rtmdet.demo
98
+ ```
99
+
100
+
101
+ ### Run model on a cloud-hosted device
102
+
103
+ In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
104
+ device. This script does the following:
105
+ * Performance check on-device on a cloud-hosted device
106
+ * Downloads compiled assets that can be deployed on-device for Android.
107
+ * Accuracy check between PyTorch and on-device outputs.
108
+
109
+ ```bash
110
+ python -m qai_hub_models.models.rtmdet.export
111
+ ```
112
+
113
+
114
+
115
+ ## How does this work?
116
+
117
+ This [export script](https://aihub.qualcomm.com/models/rtmdet/qai_hub_models/models/RTMDet/export.py)
118
+ leverages [Qualcomm® AI Hub](https://aihub.qualcomm.com/) to optimize, validate, and deploy this model
119
+ on-device. Lets go through each step below in detail:
120
+
121
+ Step 1: **Compile model for on-device deployment**
122
+
123
+ To compile a PyTorch model for on-device deployment, we first trace the model
124
+ in memory using the `jit.trace` and then call the `submit_compile_job` API.
125
+
126
+ ```python
127
+ import torch
128
 
129
+ import qai_hub as hub
130
+ from qai_hub_models.models.rtmdet import Model
131
 
132
+ # Load the model
133
+ torch_model = Model.from_pretrained()
134
+
135
+ # Device
136
+ device = hub.Device("Samsung Galaxy S24")
137
+
138
+ # Trace model
139
+ input_shape = torch_model.get_input_spec()
140
+ sample_inputs = torch_model.sample_inputs()
141
+
142
+ pt_model = torch.jit.trace(torch_model, [torch.tensor(data[0]) for _, data in sample_inputs.items()])
143
+
144
+ # Compile model on a specific device
145
+ compile_job = hub.submit_compile_job(
146
+ model=pt_model,
147
+ device=device,
148
+ input_specs=torch_model.get_input_spec(),
149
+ )
150
+
151
+ # Get target model to run on-device
152
+ target_model = compile_job.get_target_model()
153
+
154
+ ```
155
+
156
+
157
+ Step 2: **Performance profiling on cloud-hosted device**
158
+
159
+ After compiling models from step 1. Models can be profiled model on-device using the
160
+ `target_model`. Note that this scripts runs the model on a device automatically
161
+ provisioned in the cloud. Once the job is submitted, you can navigate to a
162
+ provided job URL to view a variety of on-device performance metrics.
163
+ ```python
164
+ profile_job = hub.submit_profile_job(
165
+ model=target_model,
166
+ device=device,
167
+ )
168
+
169
+ ```
170
+
171
+ Step 3: **Verify on-device accuracy**
172
+
173
+ To verify the accuracy of the model on-device, you can run on-device inference
174
+ on sample input data on the same cloud hosted device.
175
+ ```python
176
+ input_data = torch_model.sample_inputs()
177
+ inference_job = hub.submit_inference_job(
178
+ model=target_model,
179
+ device=device,
180
+ inputs=input_data,
181
+ )
182
+ on_device_output = inference_job.download_output_data()
183
+
184
+ ```
185
+ With the output of the model, you can compute like PSNR, relative errors or
186
+ spot check the output with expected output.
187
+
188
+ **Note**: This on-device profiling and inference requires access to Qualcomm®
189
+ AI Hub. [Sign up for access](https://myaccount.qualcomm.com/signup).
190
+
191
+
192
+
193
+ ## Run demo on a cloud-hosted device
194
+
195
+ You can also run the demo on-device.
196
+
197
+ ```bash
198
+ python -m qai_hub_models.models.rtmdet.demo --eval-mode on-device
199
+ ```
200
+
201
+ **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
202
+ environment, please add the following to your cell (instead of the above).
203
+ ```
204
+ %run -m qai_hub_models.models.rtmdet.demo -- --eval-mode on-device
205
+ ```
206
+
207
+
208
+ ## Deploying compiled model to Android
209
+
210
+
211
+ The models can be deployed using multiple runtimes:
212
+ - TensorFlow Lite (`.tflite` export): [This
213
+ tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
214
+ guide to deploy the .tflite model in an Android application.
215
+
216
+
217
+ - QNN (`.so` export ): This [sample
218
+ app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
219
+ provides instructions on how to use the `.so` shared library in an Android application.
220
+
221
+
222
+ ## View on Qualcomm® AI Hub
223
+ Get more details on RTMDet's performance across various devices [here](https://aihub.qualcomm.com/models/rtmdet).
224
+ Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
225
 
226
 
227
  ## License
 
238
 
239
 
240
  ## Community
241
+ * Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
242
  * For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
243
 
244
+