qaihm-bot commited on
Commit
4fa1ca3
·
verified ·
1 Parent(s): 5e662de

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

Files changed (6) hide show
  1. .gitattributes +1 -0
  2. CVT_float.dlc +3 -0
  3. CVT_float.tflite +3 -0
  4. LICENSE +1 -0
  5. README.md +253 -0
  6. tool-versions.yaml +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
+ CVT_float.dlc filter=lfs diff=lfs merge=lfs -text
CVT_float.dlc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:317f70afee9be85c3ebf66f3aced8da0d1587b661db71f8212a9ad668424e27d
3
+ size 5724988
CVT_float.tflite ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8371b3b3b7e8edf24785d8ec8dddd1dc94672ecb9854ca8668296f157118dea3
3
+ size 5431872
LICENSE ADDED
@@ -0,0 +1 @@
 
 
1
+ The license of the original trained model can be found at https://github.com/bradyz/cross_view_transformers/blob/master/LICENSE.
README.md ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: pytorch
3
+ license: other
4
+ tags:
5
+ - android
6
+ pipeline_tag: other
7
+
8
+ ---
9
+
10
+ ![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/cvt/web-assets/model_demo.png)
11
+
12
+ # CVT: Optimized for Mobile Deployment
13
+ ## Construct a map view from sensors mounted on a vehicle
14
+
15
+
16
+ Cross-View Transformer generates real-time bird's-eye view maps from multiple vehicle cameras for autonomous driving.
17
+
18
+ This model is an implementation of CVT found [here](https://github.com/bradyz/cross_view_transformers).
19
+
20
+
21
+ This repository provides scripts to run CVT on Qualcomm® devices.
22
+ More details on model performance across various devices, can be found
23
+ [here](https://aihub.qualcomm.com/models/cvt).
24
+
25
+
26
+
27
+ ### Model Details
28
+
29
+ - **Model Type:** Model_use_case.driver_assistance
30
+ - **Model Stats:**
31
+ - Model checkpoint: vehicles_50k.pt
32
+ - Inference latency: RealTime
33
+ - Input resolution: 1x6x3x224x480
34
+ - Number of parameters: 1.33M
35
+ - Model size (float): 5.18 MB
36
+
37
+ | Model | Precision | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit | Target Model
38
+ |---|---|---|---|---|---|---|---|---|
39
+ | CVT | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | TFLITE | 438.532 ms | 0 - 2052 MB | NPU | [CVT.tflite](https://huggingface.co/qualcomm/CVT/blob/main/CVT.tflite) |
40
+ | CVT | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | QNN_DLC | 428.856 ms | 0 - 2047 MB | NPU | [CVT.dlc](https://huggingface.co/qualcomm/CVT/blob/main/CVT.dlc) |
41
+ | CVT | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | TFLITE | 492.978 ms | 0 - 2582 MB | NPU | [CVT.tflite](https://huggingface.co/qualcomm/CVT/blob/main/CVT.tflite) |
42
+ | CVT | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | QNN_DLC | 483.659 ms | 7 - 2510 MB | NPU | [CVT.dlc](https://huggingface.co/qualcomm/CVT/blob/main/CVT.dlc) |
43
+ | CVT | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | TFLITE | 343.008 ms | 0 - 4 MB | NPU | [CVT.tflite](https://huggingface.co/qualcomm/CVT/blob/main/CVT.tflite) |
44
+ | CVT | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | QNN_DLC | 337.257 ms | 8 - 11 MB | NPU | [CVT.dlc](https://huggingface.co/qualcomm/CVT/blob/main/CVT.dlc) |
45
+ | CVT | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | TFLITE | 319.202 ms | 0 - 2051 MB | NPU | [CVT.tflite](https://huggingface.co/qualcomm/CVT/blob/main/CVT.tflite) |
46
+ | CVT | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | QNN_DLC | 311.571 ms | 2 - 2048 MB | NPU | [CVT.dlc](https://huggingface.co/qualcomm/CVT/blob/main/CVT.dlc) |
47
+ | CVT | float | SA7255P ADP | Qualcomm® SA7255P | TFLITE | 438.532 ms | 0 - 2052 MB | NPU | [CVT.tflite](https://huggingface.co/qualcomm/CVT/blob/main/CVT.tflite) |
48
+ | CVT | float | SA7255P ADP | Qualcomm® SA7255P | QNN_DLC | 428.856 ms | 0 - 2047 MB | NPU | [CVT.dlc](https://huggingface.co/qualcomm/CVT/blob/main/CVT.dlc) |
49
+ | CVT | float | SA8255 (Proxy) | Qualcomm® SA8255P (Proxy) | TFLITE | 347.677 ms | 0 - 4 MB | NPU | [CVT.tflite](https://huggingface.co/qualcomm/CVT/blob/main/CVT.tflite) |
50
+ | CVT | float | SA8255 (Proxy) | Qualcomm® SA8255P (Proxy) | QNN_DLC | 338.081 ms | 8 - 10 MB | NPU | [CVT.dlc](https://huggingface.co/qualcomm/CVT/blob/main/CVT.dlc) |
51
+ | CVT | float | SA8295P ADP | Qualcomm® SA8295P | TFLITE | 364.408 ms | 1 - 2156 MB | NPU | [CVT.tflite](https://huggingface.co/qualcomm/CVT/blob/main/CVT.tflite) |
52
+ | CVT | float | SA8295P ADP | Qualcomm® SA8295P | QNN_DLC | 362.017 ms | 0 - 2108 MB | NPU | [CVT.dlc](https://huggingface.co/qualcomm/CVT/blob/main/CVT.dlc) |
53
+ | CVT | float | SA8650 (Proxy) | Qualcomm® SA8650P (Proxy) | TFLITE | 344.191 ms | 0 - 3 MB | NPU | [CVT.tflite](https://huggingface.co/qualcomm/CVT/blob/main/CVT.tflite) |
54
+ | CVT | float | SA8650 (Proxy) | Qualcomm® SA8650P (Proxy) | QNN_DLC | 339.901 ms | 8 - 11 MB | NPU | [CVT.dlc](https://huggingface.co/qualcomm/CVT/blob/main/CVT.dlc) |
55
+ | CVT | float | SA8775P ADP | Qualcomm® SA8775P | TFLITE | 319.202 ms | 0 - 2051 MB | NPU | [CVT.tflite](https://huggingface.co/qualcomm/CVT/blob/main/CVT.tflite) |
56
+ | CVT | float | SA8775P ADP | Qualcomm® SA8775P | QNN_DLC | 311.571 ms | 2 - 2048 MB | NPU | [CVT.dlc](https://huggingface.co/qualcomm/CVT/blob/main/CVT.dlc) |
57
+ | CVT | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | TFLITE | 251.664 ms | 2 - 2426 MB | NPU | [CVT.tflite](https://huggingface.co/qualcomm/CVT/blob/main/CVT.tflite) |
58
+ | CVT | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | TFLITE | 197.937 ms | 0 - 2068 MB | NPU | [CVT.tflite](https://huggingface.co/qualcomm/CVT/blob/main/CVT.tflite) |
59
+ | CVT | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | QNN_DLC | 201.332 ms | 7 - 2001 MB | NPU | [CVT.dlc](https://huggingface.co/qualcomm/CVT/blob/main/CVT.dlc) |
60
+ | CVT | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen5 Mobile | TFLITE | 182.132 ms | 0 - 2057 MB | NPU | [CVT.tflite](https://huggingface.co/qualcomm/CVT/blob/main/CVT.tflite) |
61
+ | CVT | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen5 Mobile | QNN_DLC | 178.735 ms | 7 - 2095 MB | NPU | [CVT.dlc](https://huggingface.co/qualcomm/CVT/blob/main/CVT.dlc) |
62
+ | CVT | float | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN_DLC | 290.792 ms | 7 - 7 MB | NPU | [CVT.dlc](https://huggingface.co/qualcomm/CVT/blob/main/CVT.dlc) |
63
+
64
+
65
+
66
+
67
+ ## Installation
68
+
69
+
70
+ Install the package via pip:
71
+ ```bash
72
+ # NOTE: 3.10 <= PYTHON_VERSION < 3.14 is supported.
73
+ pip install nuscenes-devkit==1.2.0 --no-deps
74
+ pip install "qai-hub-models[cvt]"
75
+ ```
76
+
77
+
78
+ ## Configure Qualcomm® AI Hub Workbench to run this model on a cloud-hosted device
79
+
80
+ Sign-in to [Qualcomm® AI Hub Workbench](https://workbench.aihub.qualcomm.com/) with your
81
+ Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.
82
+
83
+ With this API token, you can configure your client to run models on the cloud
84
+ hosted devices.
85
+ ```bash
86
+ qai-hub configure --api_token API_TOKEN
87
+ ```
88
+ Navigate to [docs](https://workbench.aihub.qualcomm.com/docs/) for more information.
89
+
90
+
91
+
92
+ ## Demo off target
93
+
94
+ The package contains a simple end-to-end demo that downloads pre-trained
95
+ weights and runs this model on a sample input.
96
+
97
+ ```bash
98
+ python -m qai_hub_models.models.cvt.demo
99
+ ```
100
+
101
+ The above demo runs a reference implementation of pre-processing, model
102
+ inference, and post processing.
103
+
104
+ **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
105
+ environment, please add the following to your cell (instead of the above).
106
+ ```
107
+ %run -m qai_hub_models.models.cvt.demo
108
+ ```
109
+
110
+
111
+ ### Run model on a cloud-hosted device
112
+
113
+ In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
114
+ device. This script does the following:
115
+ * Performance check on-device on a cloud-hosted device
116
+ * Downloads compiled assets that can be deployed on-device for Android.
117
+ * Accuracy check between PyTorch and on-device outputs.
118
+
119
+ ```bash
120
+ python -m qai_hub_models.models.cvt.export
121
+ ```
122
+
123
+
124
+
125
+ ## How does this work?
126
+
127
+ This [export script](https://aihub.qualcomm.com/models/cvt/qai_hub_models/models/CVT/export.py)
128
+ leverages [Qualcomm® AI Hub](https://aihub.qualcomm.com/) to optimize, validate, and deploy this model
129
+ on-device. Lets go through each step below in detail:
130
+
131
+ Step 1: **Compile model for on-device deployment**
132
+
133
+ To compile a PyTorch model for on-device deployment, we first trace the model
134
+ in memory using the `jit.trace` and then call the `submit_compile_job` API.
135
+
136
+ ```python
137
+ import torch
138
+
139
+ import qai_hub as hub
140
+ from qai_hub_models.models.cvt import Model
141
+
142
+ # Load the model
143
+ torch_model = Model.from_pretrained()
144
+
145
+ # Device
146
+ device = hub.Device("Samsung Galaxy S25")
147
+
148
+ # Trace model
149
+ input_shape = torch_model.get_input_spec()
150
+ sample_inputs = torch_model.sample_inputs()
151
+
152
+ pt_model = torch.jit.trace(torch_model, [torch.tensor(data[0]) for _, data in sample_inputs.items()])
153
+
154
+ # Compile model on a specific device
155
+ compile_job = hub.submit_compile_job(
156
+ model=pt_model,
157
+ device=device,
158
+ input_specs=torch_model.get_input_spec(),
159
+ )
160
+
161
+ # Get target model to run on-device
162
+ target_model = compile_job.get_target_model()
163
+
164
+ ```
165
+
166
+
167
+ Step 2: **Performance profiling on cloud-hosted device**
168
+
169
+ After compiling models from step 1. Models can be profiled model on-device using the
170
+ `target_model`. Note that this scripts runs the model on a device automatically
171
+ provisioned in the cloud. Once the job is submitted, you can navigate to a
172
+ provided job URL to view a variety of on-device performance metrics.
173
+ ```python
174
+ profile_job = hub.submit_profile_job(
175
+ model=target_model,
176
+ device=device,
177
+ )
178
+
179
+ ```
180
+
181
+ Step 3: **Verify on-device accuracy**
182
+
183
+ To verify the accuracy of the model on-device, you can run on-device inference
184
+ on sample input data on the same cloud hosted device.
185
+ ```python
186
+ input_data = torch_model.sample_inputs()
187
+ inference_job = hub.submit_inference_job(
188
+ model=target_model,
189
+ device=device,
190
+ inputs=input_data,
191
+ )
192
+ on_device_output = inference_job.download_output_data()
193
+
194
+ ```
195
+ With the output of the model, you can compute like PSNR, relative errors or
196
+ spot check the output with expected output.
197
+
198
+ **Note**: This on-device profiling and inference requires access to Qualcomm®
199
+ AI Hub Workbench. [Sign up for access](https://myaccount.qualcomm.com/signup).
200
+
201
+
202
+
203
+ ## Run demo on a cloud-hosted device
204
+
205
+ You can also run the demo on-device.
206
+
207
+ ```bash
208
+ python -m qai_hub_models.models.cvt.demo --eval-mode on-device
209
+ ```
210
+
211
+ **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
212
+ environment, please add the following to your cell (instead of the above).
213
+ ```
214
+ %run -m qai_hub_models.models.cvt.demo -- --eval-mode on-device
215
+ ```
216
+
217
+
218
+ ## Deploying compiled model to Android
219
+
220
+
221
+ The models can be deployed using multiple runtimes:
222
+ - TensorFlow Lite (`.tflite` export): [This
223
+ tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
224
+ guide to deploy the .tflite model in an Android application.
225
+
226
+
227
+ - QNN (`.so` export ): This [sample
228
+ app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
229
+ provides instructions on how to use the `.so` shared library in an Android application.
230
+
231
+
232
+ ## View on Qualcomm® AI Hub
233
+ Get more details on CVT's performance across various devices [here](https://aihub.qualcomm.com/models/cvt).
234
+ Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
235
+
236
+
237
+ ## License
238
+ * The license for the original implementation of CVT can be found
239
+ [here](https://github.com/bradyz/cross_view_transformers/blob/master/LICENSE).
240
+
241
+
242
+
243
+ ## References
244
+ * [Cross-view Transformers for real-time Map-view Semantic Segmentation](https://arxiv.org/abs/2205.02833)
245
+ * [Source Model Implementation](https://github.com/bradyz/cross_view_transformers)
246
+
247
+
248
+
249
+ ## Community
250
+ * Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
251
+ * For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
252
+
253
+
tool-versions.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ tool_versions:
2
+ qnn_dlc:
3
+ qairt: 2.41.0.251128145156_191518