qaihm-bot commited on
Commit
918800b
·
verified ·
1 Parent(s): ce204fa

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

README.md ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: pytorch
3
+ license: other
4
+ tags:
5
+ - android
6
+ pipeline_tag: keypoint-detection
7
+
8
+ ---
9
+
10
+ ![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/rtmpose_body2d/web-assets/model_demo.png)
11
+
12
+ # RTMPose-Body2d: Optimized for Mobile Deployment
13
+ ## Human pose estimation
14
+
15
+
16
+ RTMPose is a machine learning model that detects human pose and returns a location and confidence for each of 133 joints.
17
+
18
+ This model is an implementation of RTMPose-Body2d found [here](https://github.com/open-mmlab/mmpose/tree/main/projects/rtmpose).
19
+
20
+
21
+ This repository provides scripts to run RTMPose-Body2d on Qualcomm® devices.
22
+ More details on model performance across various devices, can be found
23
+ [here](https://aihub.qualcomm.com/models/rtmpose_body2d).
24
+
25
+
26
+ ### Model Details
27
+
28
+ - **Model Type:** Model_use_case.pose_estimation
29
+ - **Model Stats:**
30
+ - Input resolution: 256x192
31
+ - Number of parameters: 17.9M
32
+ - Model size (float): 68.5 MB
33
+ - Model size (w8a8): 17.52MB
34
+
35
+ | Model | Precision | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit | Target Model
36
+ |---|---|---|---|---|---|---|---|---|
37
+ | RTMPose-Body2d | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | TFLITE | 46.335 ms | 0 - 32 MB | NPU | [RTMPose-Body2d.tflite](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d.tflite) |
38
+ | RTMPose-Body2d | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | QNN | 46.222 ms | 1 - 10 MB | NPU | Use Export Script |
39
+ | RTMPose-Body2d | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | TFLITE | 3.033 ms | 0 - 62 MB | NPU | [RTMPose-Body2d.tflite](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d.tflite) |
40
+ | RTMPose-Body2d | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | QNN | 3.544 ms | 0 - 31 MB | NPU | Use Export Script |
41
+ | RTMPose-Body2d | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | TFLITE | 1.873 ms | 0 - 253 MB | NPU | [RTMPose-Body2d.tflite](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d.tflite) |
42
+ | RTMPose-Body2d | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | QNN | 1.776 ms | 1 - 3 MB | NPU | Use Export Script |
43
+ | RTMPose-Body2d | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | TFLITE | 2.595 ms | 0 - 32 MB | NPU | [RTMPose-Body2d.tflite](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d.tflite) |
44
+ | RTMPose-Body2d | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | QNN | 2.456 ms | 1 - 10 MB | NPU | Use Export Script |
45
+ | RTMPose-Body2d | float | SA7255P ADP | Qualcomm® SA7255P | TFLITE | 46.335 ms | 0 - 32 MB | NPU | [RTMPose-Body2d.tflite](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d.tflite) |
46
+ | RTMPose-Body2d | float | SA7255P ADP | Qualcomm® SA7255P | QNN | 46.222 ms | 1 - 10 MB | NPU | Use Export Script |
47
+ | RTMPose-Body2d | float | SA8255 (Proxy) | Qualcomm® SA8255P (Proxy) | TFLITE | 1.868 ms | 0 - 251 MB | NPU | [RTMPose-Body2d.tflite](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d.tflite) |
48
+ | RTMPose-Body2d | float | SA8255 (Proxy) | Qualcomm® SA8255P (Proxy) | QNN | 1.786 ms | 1 - 3 MB | NPU | Use Export Script |
49
+ | RTMPose-Body2d | float | SA8295P ADP | Qualcomm® SA8295P | TFLITE | 3.625 ms | 0 - 35 MB | NPU | [RTMPose-Body2d.tflite](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d.tflite) |
50
+ | RTMPose-Body2d | float | SA8295P ADP | Qualcomm® SA8295P | QNN | 3.56 ms | 0 - 17 MB | NPU | Use Export Script |
51
+ | RTMPose-Body2d | float | SA8650 (Proxy) | Qualcomm® SA8650P (Proxy) | TFLITE | 1.87 ms | 0 - 263 MB | NPU | [RTMPose-Body2d.tflite](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d.tflite) |
52
+ | RTMPose-Body2d | float | SA8650 (Proxy) | Qualcomm® SA8650P (Proxy) | QNN | 1.784 ms | 1 - 3 MB | NPU | Use Export Script |
53
+ | RTMPose-Body2d | float | SA8775P ADP | Qualcomm® SA8775P | TFLITE | 2.595 ms | 0 - 32 MB | NPU | [RTMPose-Body2d.tflite](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d.tflite) |
54
+ | RTMPose-Body2d | float | SA8775P ADP | Qualcomm® SA8775P | QNN | 2.456 ms | 1 - 10 MB | NPU | Use Export Script |
55
+ | RTMPose-Body2d | float | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | TFLITE | 1.836 ms | 0 - 261 MB | NPU | [RTMPose-Body2d.tflite](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d.tflite) |
56
+ | RTMPose-Body2d | float | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | QNN | 1.782 ms | 0 - 114 MB | NPU | Use Export Script |
57
+ | RTMPose-Body2d | float | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | ONNX | 1.987 ms | 0 - 94 MB | NPU | [RTMPose-Body2d.onnx](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d.onnx) |
58
+ | RTMPose-Body2d | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | TFLITE | 1.377 ms | 0 - 60 MB | NPU | [RTMPose-Body2d.tflite](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d.tflite) |
59
+ | RTMPose-Body2d | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | QNN | 1.31 ms | 0 - 30 MB | NPU | Use Export Script |
60
+ | RTMPose-Body2d | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | ONNX | 1.436 ms | 0 - 30 MB | NPU | [RTMPose-Body2d.onnx](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d.onnx) |
61
+ | RTMPose-Body2d | float | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | TFLITE | 1.324 ms | 0 - 38 MB | NPU | [RTMPose-Body2d.tflite](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d.tflite) |
62
+ | RTMPose-Body2d | float | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | QNN | 1.267 ms | 0 - 21 MB | NPU | Use Export Script |
63
+ | RTMPose-Body2d | float | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | ONNX | 1.443 ms | 0 - 23 MB | NPU | [RTMPose-Body2d.onnx](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d.onnx) |
64
+ | RTMPose-Body2d | float | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN | 1.873 ms | 1 - 1 MB | NPU | Use Export Script |
65
+ | RTMPose-Body2d | float | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 1.973 ms | 37 - 37 MB | NPU | [RTMPose-Body2d.onnx](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d.onnx) |
66
+ | RTMPose-Body2d | w8a16 | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | ONNX | 2.799 ms | 0 - 33 MB | NPU | [RTMPose-Body2d.onnx](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d_w8a16.onnx) |
67
+ | RTMPose-Body2d | w8a16 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | ONNX | 1.962 ms | 0 - 48 MB | NPU | [RTMPose-Body2d.onnx](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d_w8a16.onnx) |
68
+ | RTMPose-Body2d | w8a16 | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | ONNX | 2.013 ms | 0 - 32 MB | NPU | [RTMPose-Body2d.onnx](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d_w8a16.onnx) |
69
+ | RTMPose-Body2d | w8a16 | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 3.028 ms | 19 - 19 MB | NPU | [RTMPose-Body2d.onnx](https://huggingface.co/qualcomm/RTMPose-Body2d/blob/main/RTMPose-Body2d_w8a16.onnx) |
70
+
71
+
72
+
73
+
74
+ ## Installation
75
+
76
+
77
+ Install the package via pip:
78
+ ```bash
79
+ pip install "qai-hub-models[rtmpose-body2d]" 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
80
+ ```
81
+
82
+
83
+ ## Configure Qualcomm® AI Hub to run this model on a cloud-hosted device
84
+
85
+ Sign-in to [Qualcomm® AI Hub](https://app.aihub.qualcomm.com/) with your
86
+ Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.
87
+
88
+ With this API token, you can configure your client to run models on the cloud
89
+ hosted devices.
90
+ ```bash
91
+ qai-hub configure --api_token API_TOKEN
92
+ ```
93
+ Navigate to [docs](https://app.aihub.qualcomm.com/docs/) for more information.
94
+
95
+
96
+
97
+ ## Demo off target
98
+
99
+ The package contains a simple end-to-end demo that downloads pre-trained
100
+ weights and runs this model on a sample input.
101
+
102
+ ```bash
103
+ python -m qai_hub_models.models.rtmpose_body2d.demo
104
+ ```
105
+
106
+ The above demo runs a reference implementation of pre-processing, model
107
+ inference, and post processing.
108
+
109
+ **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
110
+ environment, please add the following to your cell (instead of the above).
111
+ ```
112
+ %run -m qai_hub_models.models.rtmpose_body2d.demo
113
+ ```
114
+
115
+
116
+ ### Run model on a cloud-hosted device
117
+
118
+ In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
119
+ device. This script does the following:
120
+ * Performance check on-device on a cloud-hosted device
121
+ * Downloads compiled assets that can be deployed on-device for Android.
122
+ * Accuracy check between PyTorch and on-device outputs.
123
+
124
+ ```bash
125
+ python -m qai_hub_models.models.rtmpose_body2d.export
126
+ ```
127
+ ```
128
+ Profiling Results
129
+ ------------------------------------------------------------
130
+ RTMPose-Body2d
131
+ Device : cs_8275 (ANDROID 14)
132
+ Runtime : TFLITE
133
+ Estimated inference time (ms) : 46.3
134
+ Estimated peak memory usage (MB): [0, 32]
135
+ Total # Ops : 256
136
+ Compute Unit(s) : npu (256 ops) gpu (0 ops) cpu (0 ops)
137
+ ```
138
+
139
+
140
+ ## How does this work?
141
+
142
+ This [export script](https://aihub.qualcomm.com/models/rtmpose_body2d/qai_hub_models/models/RTMPose-Body2d/export.py)
143
+ leverages [Qualcomm® AI Hub](https://aihub.qualcomm.com/) to optimize, validate, and deploy this model
144
+ on-device. Lets go through each step below in detail:
145
+
146
+ Step 1: **Compile model for on-device deployment**
147
+
148
+ To compile a PyTorch model for on-device deployment, we first trace the model
149
+ in memory using the `jit.trace` and then call the `submit_compile_job` API.
150
+
151
+ ```python
152
+ import torch
153
+
154
+ import qai_hub as hub
155
+ from qai_hub_models.models.rtmpose_body2d import Model
156
+
157
+ # Load the model
158
+ torch_model = Model.from_pretrained()
159
+
160
+ # Device
161
+ device = hub.Device("Samsung Galaxy S24")
162
+
163
+ # Trace model
164
+ input_shape = torch_model.get_input_spec()
165
+ sample_inputs = torch_model.sample_inputs()
166
+
167
+ pt_model = torch.jit.trace(torch_model, [torch.tensor(data[0]) for _, data in sample_inputs.items()])
168
+
169
+ # Compile model on a specific device
170
+ compile_job = hub.submit_compile_job(
171
+ model=pt_model,
172
+ device=device,
173
+ input_specs=torch_model.get_input_spec(),
174
+ )
175
+
176
+ # Get target model to run on-device
177
+ target_model = compile_job.get_target_model()
178
+
179
+ ```
180
+
181
+
182
+ Step 2: **Performance profiling on cloud-hosted device**
183
+
184
+ After compiling models from step 1. Models can be profiled model on-device using the
185
+ `target_model`. Note that this scripts runs the model on a device automatically
186
+ provisioned in the cloud. Once the job is submitted, you can navigate to a
187
+ provided job URL to view a variety of on-device performance metrics.
188
+ ```python
189
+ profile_job = hub.submit_profile_job(
190
+ model=target_model,
191
+ device=device,
192
+ )
193
+
194
+ ```
195
+
196
+ Step 3: **Verify on-device accuracy**
197
+
198
+ To verify the accuracy of the model on-device, you can run on-device inference
199
+ on sample input data on the same cloud hosted device.
200
+ ```python
201
+ input_data = torch_model.sample_inputs()
202
+ inference_job = hub.submit_inference_job(
203
+ model=target_model,
204
+ device=device,
205
+ inputs=input_data,
206
+ )
207
+ on_device_output = inference_job.download_output_data()
208
+
209
+ ```
210
+ With the output of the model, you can compute like PSNR, relative errors or
211
+ spot check the output with expected output.
212
+
213
+ **Note**: This on-device profiling and inference requires access to Qualcomm®
214
+ AI Hub. [Sign up for access](https://myaccount.qualcomm.com/signup).
215
+
216
+
217
+
218
+ ## Run demo on a cloud-hosted device
219
+
220
+ You can also run the demo on-device.
221
+
222
+ ```bash
223
+ python -m qai_hub_models.models.rtmpose_body2d.demo --eval-mode on-device
224
+ ```
225
+
226
+ **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
227
+ environment, please add the following to your cell (instead of the above).
228
+ ```
229
+ %run -m qai_hub_models.models.rtmpose_body2d.demo -- --eval-mode on-device
230
+ ```
231
+
232
+
233
+ ## Deploying compiled model to Android
234
+
235
+
236
+ The models can be deployed using multiple runtimes:
237
+ - TensorFlow Lite (`.tflite` export): [This
238
+ tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
239
+ guide to deploy the .tflite model in an Android application.
240
+
241
+
242
+ - QNN (`.so` export ): This [sample
243
+ app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
244
+ provides instructions on how to use the `.so` shared library in an Android application.
245
+
246
+
247
+ ## View on Qualcomm® AI Hub
248
+ Get more details on RTMPose-Body2d's performance across various devices [here](https://aihub.qualcomm.com/models/rtmpose_body2d).
249
+ Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
250
+
251
+
252
+ ## License
253
+ * The license for the original implementation of RTMPose-Body2d can be found
254
+ [here](https://github.com/open-mmlab/mmpose/blob/main/LICENSE).
255
+ * The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf)
256
+
257
+
258
+
259
+ ## References
260
+ * [RTMPose: Real-Time Multi-Person Pose Estimation based on MMPose](https://arxiv.org/abs/2303.07399)
261
+ * [Source Model Implementation](https://github.com/open-mmlab/mmpose/tree/main/projects/rtmpose)
262
+
263
+
264
+
265
+ ## Community
266
+ * Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
267
+ * For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
268
+
269
+
RTMPose-Body2d.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2925e13813c91928dfae95035ef61bf2d1f43978546b5286cc701f60bfb0b2aa
3
+ size 71842158
RTMPose-Body2d.tflite ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a6d7b949903d4a9b8293c1859e03a1355e8edc04bf04d609d4c39a9670edfa87
3
+ size 71821100
RTMPose-Body2d_w8a16.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:706d38d3943100b2ed8654a94887eeaaf6e2f41c220d8c53612f1e25322efdb1
3
+ size 72145341