qaihm-bot commited on
Commit
8922adc
·
verified ·
1 Parent(s): ca90aa0

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

Files changed (5) hide show
  1. .gitattributes +1 -0
  2. README.md +231 -0
  3. SalsaNext.dlc +3 -0
  4. SalsaNext.onnx +3 -0
  5. SalsaNext.tflite +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ SalsaNext.dlc filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: pytorch
3
+ license: other
4
+ tags:
5
+ - android
6
+ pipeline_tag: image-segmentation
7
+
8
+ ---
9
+
10
+ ![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/salsanext/web-assets/model_demo.png)
11
+
12
+ # SalsaNext: Optimized for Mobile Deployment
13
+ ## Semantic segmentation model optimized for LiDAR point cloud data
14
+
15
+ SalsaNext is a LiDAR-based semantic segmentation model designed for efficient and accurate
16
+
17
+ This repository provides scripts to run SalsaNext on Qualcomm® devices.
18
+ More details on model performance across various devices, can be found
19
+ [here](https://aihub.qualcomm.com/models/salsanext).
20
+
21
+
22
+ ### Model Details
23
+
24
+ - **Model Type:** Model_use_case.semantic_segmentation
25
+ - **Model Stats:**
26
+ - Model checkpoint: SalsaNext
27
+ - Input resolution: 1x5x64x2048
28
+ - Model size: 108 MB
29
+
30
+ | Model | Precision | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit | Target Model
31
+ |---|---|---|---|---|---|---|---|---|
32
+ | SalsaNext | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | TFLITE | 148.718 ms | 64 - 93 MB | NPU | [SalsaNext.tflite](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.tflite) |
33
+ | SalsaNext | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | QNN_DLC | 115.246 ms | 0 - 40 MB | NPU | [SalsaNext.dlc](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.dlc) |
34
+ | SalsaNext | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | TFLITE | 65.38 ms | 64 - 106 MB | NPU | [SalsaNext.tflite](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.tflite) |
35
+ | SalsaNext | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | QNN_DLC | 56.086 ms | 3 - 61 MB | NPU | [SalsaNext.dlc](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.dlc) |
36
+ | SalsaNext | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | TFLITE | 47.762 ms | 64 - 89 MB | NPU | [SalsaNext.tflite](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.tflite) |
37
+ | SalsaNext | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | QNN_DLC | 31.235 ms | 3 - 16 MB | NPU | [SalsaNext.dlc](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.dlc) |
38
+ | SalsaNext | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | TFLITE | 58.582 ms | 64 - 93 MB | NPU | [SalsaNext.tflite](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.tflite) |
39
+ | SalsaNext | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | QNN_DLC | 36.864 ms | 0 - 41 MB | NPU | [SalsaNext.dlc](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.dlc) |
40
+ | SalsaNext | float | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | TFLITE | 48.477 ms | 64 - 89 MB | NPU | [SalsaNext.tflite](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.tflite) |
41
+ | SalsaNext | float | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | QNN_DLC | 31.188 ms | 3 - 19 MB | NPU | [SalsaNext.dlc](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.dlc) |
42
+ | SalsaNext | float | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | ONNX | 32.053 ms | 20 - 65 MB | NPU | [SalsaNext.onnx](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.onnx) |
43
+ | SalsaNext | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | TFLITE | 36.615 ms | 63 - 104 MB | NPU | [SalsaNext.tflite](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.tflite) |
44
+ | SalsaNext | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | QNN_DLC | 23.162 ms | 3 - 46 MB | NPU | [SalsaNext.dlc](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.dlc) |
45
+ | SalsaNext | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | ONNX | 23.744 ms | 24 - 77 MB | NPU | [SalsaNext.onnx](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.onnx) |
46
+ | SalsaNext | float | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | TFLITE | 33.594 ms | 64 - 98 MB | NPU | [SalsaNext.tflite](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.tflite) |
47
+ | SalsaNext | float | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | QNN_DLC | 17.52 ms | 3 - 47 MB | NPU | [SalsaNext.dlc](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.dlc) |
48
+ | SalsaNext | float | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | ONNX | 18.546 ms | 25 - 71 MB | NPU | [SalsaNext.onnx](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.onnx) |
49
+ | SalsaNext | float | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN_DLC | 31.316 ms | 40 - 40 MB | NPU | [SalsaNext.dlc](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.dlc) |
50
+ | SalsaNext | float | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 32.14 ms | 35 - 35 MB | NPU | [SalsaNext.onnx](https://huggingface.co/qualcomm/SalsaNext/blob/main/SalsaNext.onnx) |
51
+
52
+
53
+
54
+
55
+ ## Installation
56
+
57
+
58
+ Install the package via pip:
59
+ ```bash
60
+ pip install qai-hub-models
61
+ ```
62
+
63
+
64
+ ## Configure Qualcomm® AI Hub to run this model on a cloud-hosted device
65
+
66
+ Sign-in to [Qualcomm® AI Hub](https://app.aihub.qualcomm.com/) with your
67
+ Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.
68
+
69
+ With this API token, you can configure your client to run models on the cloud
70
+ hosted devices.
71
+ ```bash
72
+ qai-hub configure --api_token API_TOKEN
73
+ ```
74
+ Navigate to [docs](https://app.aihub.qualcomm.com/docs/) for more information.
75
+
76
+
77
+
78
+ ## Demo off target
79
+
80
+ The package contains a simple end-to-end demo that downloads pre-trained
81
+ weights and runs this model on a sample input.
82
+
83
+ ```bash
84
+ python -m qai_hub_models.models.salsanext.demo
85
+ ```
86
+
87
+ The above demo runs a reference implementation of pre-processing, model
88
+ inference, and post processing.
89
+
90
+ **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
91
+ environment, please add the following to your cell (instead of the above).
92
+ ```
93
+ %run -m qai_hub_models.models.salsanext.demo
94
+ ```
95
+
96
+
97
+ ### Run model on a cloud-hosted device
98
+
99
+ In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
100
+ device. This script does the following:
101
+ * Performance check on-device on a cloud-hosted device
102
+ * Downloads compiled assets that can be deployed on-device for Android.
103
+ * Accuracy check between PyTorch and on-device outputs.
104
+
105
+ ```bash
106
+ python -m qai_hub_models.models.salsanext.export
107
+ ```
108
+ ```
109
+ Profiling Results
110
+ ------------------------------------------------------------
111
+ SalsaNext
112
+ Device : cs_8275 (ANDROID 14)
113
+ Runtime : TFLITE
114
+ Estimated inference time (ms) : 148.7
115
+ Estimated peak memory usage (MB): [64, 93]
116
+ Total # Ops : 249
117
+ Compute Unit(s) : npu (237 ops) gpu (0 ops) cpu (12 ops)
118
+ ```
119
+
120
+
121
+ ## How does this work?
122
+
123
+ This [export script](https://aihub.qualcomm.com/models/salsanext/qai_hub_models/models/SalsaNext/export.py)
124
+ leverages [Qualcomm® AI Hub](https://aihub.qualcomm.com/) to optimize, validate, and deploy this model
125
+ on-device. Lets go through each step below in detail:
126
+
127
+ Step 1: **Compile model for on-device deployment**
128
+
129
+ To compile a PyTorch model for on-device deployment, we first trace the model
130
+ in memory using the `jit.trace` and then call the `submit_compile_job` API.
131
+
132
+ ```python
133
+ import torch
134
+
135
+ import qai_hub as hub
136
+ from qai_hub_models.models.salsanext import Model
137
+
138
+ # Load the model
139
+ torch_model = Model.from_pretrained()
140
+
141
+ # Device
142
+ device = hub.Device("Samsung Galaxy S24")
143
+
144
+ # Trace model
145
+ input_shape = torch_model.get_input_spec()
146
+ sample_inputs = torch_model.sample_inputs()
147
+
148
+ pt_model = torch.jit.trace(torch_model, [torch.tensor(data[0]) for _, data in sample_inputs.items()])
149
+
150
+ # Compile model on a specific device
151
+ compile_job = hub.submit_compile_job(
152
+ model=pt_model,
153
+ device=device,
154
+ input_specs=torch_model.get_input_spec(),
155
+ )
156
+
157
+ # Get target model to run on-device
158
+ target_model = compile_job.get_target_model()
159
+
160
+ ```
161
+
162
+
163
+ Step 2: **Performance profiling on cloud-hosted device**
164
+
165
+ After compiling models from step 1. Models can be profiled model on-device using the
166
+ `target_model`. Note that this scripts runs the model on a device automatically
167
+ provisioned in the cloud. Once the job is submitted, you can navigate to a
168
+ provided job URL to view a variety of on-device performance metrics.
169
+ ```python
170
+ profile_job = hub.submit_profile_job(
171
+ model=target_model,
172
+ device=device,
173
+ )
174
+
175
+ ```
176
+
177
+ Step 3: **Verify on-device accuracy**
178
+
179
+ To verify the accuracy of the model on-device, you can run on-device inference
180
+ on sample input data on the same cloud hosted device.
181
+ ```python
182
+ input_data = torch_model.sample_inputs()
183
+ inference_job = hub.submit_inference_job(
184
+ model=target_model,
185
+ device=device,
186
+ inputs=input_data,
187
+ )
188
+ on_device_output = inference_job.download_output_data()
189
+
190
+ ```
191
+ With the output of the model, you can compute like PSNR, relative errors or
192
+ spot check the output with expected output.
193
+
194
+ **Note**: This on-device profiling and inference requires access to Qualcomm®
195
+ AI Hub. [Sign up for access](https://myaccount.qualcomm.com/signup).
196
+
197
+
198
+
199
+
200
+ ## Deploying compiled model to Android
201
+
202
+
203
+ The models can be deployed using multiple runtimes:
204
+ - TensorFlow Lite (`.tflite` export): [This
205
+ tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
206
+ guide to deploy the .tflite model in an Android application.
207
+
208
+
209
+ - QNN (`.so` export ): This [sample
210
+ app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
211
+ provides instructions on how to use the `.so` shared library in an Android application.
212
+
213
+
214
+ ## View on Qualcomm® AI Hub
215
+ Get more details on SalsaNext's performance across various devices [here](https://aihub.qualcomm.com/models/salsanext).
216
+ Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
217
+
218
+
219
+ ## License
220
+ * The license for the original implementation of SalsaNext can be found
221
+ [here](https://github.com/TiagoCortinhal/SalsaNext/blob/master/LICENSE).
222
+ * 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)
223
+
224
+
225
+
226
+
227
+ ## Community
228
+ * Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
229
+ * For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
230
+
231
+
SalsaNext.dlc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c4955ad9883f6d8a11e9f29dd0b50089b431c597f5a0285fe75980bd71d45fd
3
+ size 27054185
SalsaNext.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:47342cc847c2d0a038975071ea9d484f46e1830aa6c2cadafdc0e2864ff86b5e
3
+ size 26962206
SalsaNext.tflite ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e22ef412c86ecab0b7cb1178aae5d814669d686e2b074ed64c346657ca4768a0
3
+ size 26903628