Image Classification
PyTorch
backbone
android
qaihm-bot commited on
Commit
9611afd
·
verified ·
1 Parent(s): 8badf37

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

README.md CHANGED
@@ -10,282 +10,139 @@ pipeline_tag: image-classification
10
 
11
  ![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/vit/web-assets/model_demo.png)
12
 
13
- # VIT: Optimized for Mobile Deployment
14
- ## Imagenet classifier and general purpose backbone
15
-
16
 
17
  VIT is a machine learning model that can classify images from the Imagenet dataset. It can also be used as a backbone in building more complex models for specific use cases.
18
 
19
- This model is an implementation of VIT found [here](https://github.com/pytorch/vision/blob/main/torchvision/models/vision_transformer.py).
20
-
21
-
22
- This repository provides scripts to run VIT on Qualcomm® devices.
23
- More details on model performance across various devices, can be found
24
- [here](https://aihub.qualcomm.com/models/vit).
25
-
26
-
27
-
28
- ### Model Details
29
-
30
- - **Model Type:** Model_use_case.image_classification
31
- - **Model Stats:**
32
- - Model checkpoint: Imagenet
33
- - Input resolution: 224x224
34
- - Number of parameters: 86.6M
35
- - Model size (float): 330 MB
36
- - Model size (w8a16): 86.2 MB
37
- - Model size (w8a8): 83.2 MB
38
-
39
- | Model | Precision | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit | Target Model
40
- |---|---|---|---|---|---|---|---|---|
41
- | VIT | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | TFLITE | 35.901 ms | 0 - 433 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT.tflite) |
42
- | VIT | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | QNN_DLC | 40.119 ms | 1 - 424 MB | NPU | [VIT.dlc](https://huggingface.co/qualcomm/VIT/blob/main/VIT.dlc) |
43
- | VIT | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | TFLITE | 14.66 ms | 0 - 462 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT.tflite) |
44
- | VIT | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | QNN_DLC | 19.999 ms | 1 - 451 MB | NPU | [VIT.dlc](https://huggingface.co/qualcomm/VIT/blob/main/VIT.dlc) |
45
- | VIT | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | TFLITE | 8.092 ms | 0 - 3 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT.tflite) |
46
- | VIT | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | QNN_DLC | 11.213 ms | 1 - 3 MB | NPU | [VIT.dlc](https://huggingface.co/qualcomm/VIT/blob/main/VIT.dlc) |
47
- | VIT | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | ONNX | 13.336 ms | 0 - 194 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT.onnx.zip) |
48
- | VIT | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | TFLITE | 11.041 ms | 0 - 433 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT.tflite) |
49
- | VIT | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | QNN_DLC | 14.003 ms | 1 - 424 MB | NPU | [VIT.dlc](https://huggingface.co/qualcomm/VIT/blob/main/VIT.dlc) |
50
- | VIT | float | SA7255P ADP | Qualcomm® SA7255P | TFLITE | 35.901 ms | 0 - 433 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT.tflite) |
51
- | VIT | float | SA7255P ADP | Qualcomm® SA7255P | QNN_DLC | 40.119 ms | 1 - 424 MB | NPU | [VIT.dlc](https://huggingface.co/qualcomm/VIT/blob/main/VIT.dlc) |
52
- | VIT | float | SA8295P ADP | Qualcomm® SA8295P | TFLITE | 13.58 ms | 0 - 425 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT.tflite) |
53
- | VIT | float | SA8295P ADP | Qualcomm® SA8295P | QNN_DLC | 17.087 ms | 0 - 424 MB | NPU | [VIT.dlc](https://huggingface.co/qualcomm/VIT/blob/main/VIT.dlc) |
54
- | VIT | float | SA8775P ADP | Qualcomm® SA8775P | TFLITE | 11.041 ms | 0 - 433 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT.tflite) |
55
- | VIT | float | SA8775P ADP | Qualcomm® SA8775P | QNN_DLC | 14.003 ms | 1 - 424 MB | NPU | [VIT.dlc](https://huggingface.co/qualcomm/VIT/blob/main/VIT.dlc) |
56
- | VIT | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | TFLITE | 5.952 ms | 0 - 473 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT.tflite) |
57
- | VIT | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | QNN_DLC | 7.737 ms | 1 - 460 MB | NPU | [VIT.dlc](https://huggingface.co/qualcomm/VIT/blob/main/VIT.dlc) |
58
- | VIT | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | ONNX | 9.097 ms | 1 - 476 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT.onnx.zip) |
59
- | VIT | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | TFLITE | 4.087 ms | 0 - 429 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT.tflite) |
60
- | VIT | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | QNN_DLC | 5.473 ms | 1 - 427 MB | NPU | [VIT.dlc](https://huggingface.co/qualcomm/VIT/blob/main/VIT.dlc) |
61
- | VIT | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | ONNX | 6.313 ms | 1 - 421 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT.onnx.zip) |
62
- | VIT | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | TFLITE | 3.324 ms | 0 - 426 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT.tflite) |
63
- | VIT | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | QNN_DLC | 4.234 ms | 1 - 421 MB | NPU | [VIT.dlc](https://huggingface.co/qualcomm/VIT/blob/main/VIT.dlc) |
64
- | VIT | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | ONNX | 4.856 ms | 1 - 414 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT.onnx.zip) |
65
- | VIT | float | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN_DLC | 11.898 ms | 1 - 1 MB | NPU | [VIT.dlc](https://huggingface.co/qualcomm/VIT/blob/main/VIT.dlc) |
66
- | VIT | float | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 13.877 ms | 171 - 171 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT.onnx.zip) |
67
- | VIT | w8a16 | Dragonwing Q-6690 MTP | Qualcomm® QCM6690 | ONNX | 620.662 ms | 87 - 108 MB | CPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a16.onnx.zip) |
68
- | VIT | w8a16 | Dragonwing RB3 Gen 2 Vision Kit | Qualcomm® QCS6490 | ONNX | 1117.411 ms | 47 - 75 MB | CPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a16.onnx.zip) |
69
- | VIT | w8a16 | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | ONNX | 277.023 ms | 55 - 60 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a16.onnx.zip) |
70
- | VIT | w8a16 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | ONNX | 242.94 ms | 59 - 306 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a16.onnx.zip) |
71
- | VIT | w8a16 | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | ONNX | 202.773 ms | 53 - 208 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a16.onnx.zip) |
72
- | VIT | w8a16 | Snapdragon 7 Gen 4 QRD | Snapdragon® 7 Gen 4 Mobile | ONNX | 592.98 ms | 86 - 106 MB | CPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a16.onnx.zip) |
73
- | VIT | w8a16 | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | ONNX | 182.106 ms | 57 - 217 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a16.onnx.zip) |
74
- | VIT | w8a16 | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 167.05 ms | 71 - 71 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a16.onnx.zip) |
75
- | VIT | w8a8 | Dragonwing Q-6690 MTP | Qualcomm® QCM6690 | TFLITE | 88.264 ms | 2 - 157 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.tflite) |
76
- | VIT | w8a8 | Dragonwing Q-6690 MTP | Qualcomm® QCM6690 | ONNX | 477.555 ms | 69 - 92 MB | CPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.onnx.zip) |
77
- | VIT | w8a8 | Dragonwing RB3 Gen 2 Vision Kit | Qualcomm® QCS6490 | TFLITE | 71.779 ms | 1 - 99 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.tflite) |
78
- | VIT | w8a8 | Dragonwing RB3 Gen 2 Vision Kit | Qualcomm® QCS6490 | ONNX | 873.83 ms | 67 - 100 MB | CPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.onnx.zip) |
79
- | VIT | w8a8 | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | TFLITE | 14.406 ms | 0 - 165 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.tflite) |
80
- | VIT | w8a8 | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | TFLITE | 8.012 ms | 0 - 263 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.tflite) |
81
- | VIT | w8a8 | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | TFLITE | 6.753 ms | 0 - 4 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.tflite) |
82
- | VIT | w8a8 | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | ONNX | 289.68 ms | 42 - 77 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.onnx.zip) |
83
- | VIT | w8a8 | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | TFLITE | 32.057 ms | 0 - 165 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.tflite) |
84
- | VIT | w8a8 | SA7255P ADP | Qualcomm® SA7255P | TFLITE | 14.406 ms | 0 - 165 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.tflite) |
85
- | VIT | w8a8 | SA8295P ADP | Qualcomm® SA8295P | TFLITE | 8.944 ms | 0 - 168 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.tflite) |
86
- | VIT | w8a8 | SA8775P ADP | Qualcomm® SA8775P | TFLITE | 32.057 ms | 0 - 165 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.tflite) |
87
- | VIT | w8a8 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | TFLITE | 4.746 ms | 0 - 264 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.tflite) |
88
- | VIT | w8a8 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | ONNX | 229.346 ms | 60 - 278 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.onnx.zip) |
89
- | VIT | w8a8 | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | TFLITE | 3.389 ms | 0 - 170 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.tflite) |
90
- | VIT | w8a8 | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | ONNX | 199.154 ms | 32 - 175 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.onnx.zip) |
91
- | VIT | w8a8 | Snapdragon 7 Gen 4 QRD | Snapdragon® 7 Gen 4 Mobile | TFLITE | 20.39 ms | 2 - 149 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.tflite) |
92
- | VIT | w8a8 | Snapdragon 7 Gen 4 QRD | Snapdragon® 7 Gen 4 Mobile | ONNX | 461.702 ms | 38 - 58 MB | CPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.onnx.zip) |
93
- | VIT | w8a8 | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | TFLITE | 2.279 ms | 0 - 172 MB | NPU | [VIT.tflite](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.tflite) |
94
- | VIT | w8a8 | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | ONNX | 181.066 ms | 56 - 206 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.onnx.zip) |
95
- | VIT | w8a8 | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 139.815 ms | 69 - 69 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8.onnx.zip) |
96
- | VIT | w8a8_mixed_int16 | Dragonwing Q-6690 MTP | Qualcomm® QCM6690 | ONNX | 507.94 ms | 89 - 113 MB | CPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8_mixed_int16.onnx.zip) |
97
- | VIT | w8a8_mixed_int16 | Dragonwing RB3 Gen 2 Vision Kit | Qualcomm® QCS6490 | ONNX | 893.549 ms | 37 - 77 MB | CPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8_mixed_int16.onnx.zip) |
98
- | VIT | w8a8_mixed_int16 | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | ONNX | 341.516 ms | 51 - 83 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8_mixed_int16.onnx.zip) |
99
- | VIT | w8a8_mixed_int16 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | ONNX | 279.907 ms | 78 - 328 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8_mixed_int16.onnx.zip) |
100
- | VIT | w8a8_mixed_int16 | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | ONNX | 245.32 ms | 80 - 242 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8_mixed_int16.onnx.zip) |
101
- | VIT | w8a8_mixed_int16 | Snapdragon 7 Gen 4 QRD | Snapdragon® 7 Gen 4 Mobile | ONNX | 488.346 ms | 87 - 110 MB | CPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8_mixed_int16.onnx.zip) |
102
- | VIT | w8a8_mixed_int16 | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | ONNX | 225.812 ms | 75 - 236 MB | NPU | [VIT.onnx.zip](https://huggingface.co/qualcomm/VIT/blob/main/VIT_w8a8_mixed_int16.onnx.zip) |
103
-
104
-
105
-
106
-
107
- ## Installation
108
-
109
-
110
- Install the package via pip:
111
- ```bash
112
- pip install qai-hub-models
113
- ```
114
-
115
-
116
- ## Configure Qualcomm® AI Hub Workbench to run this model on a cloud-hosted device
117
-
118
- Sign-in to [Qualcomm® AI Hub Workbench](https://workbench.aihub.qualcomm.com/) with your
119
- Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.
120
-
121
- With this API token, you can configure your client to run models on the cloud
122
- hosted devices.
123
- ```bash
124
- qai-hub configure --api_token API_TOKEN
125
- ```
126
- Navigate to [docs](https://workbench.aihub.qualcomm.com/docs/) for more information.
127
-
128
-
129
-
130
- ## Demo off target
131
-
132
- The package contains a simple end-to-end demo that downloads pre-trained
133
- weights and runs this model on a sample input.
134
-
135
- ```bash
136
- python -m qai_hub_models.models.vit.demo
137
- ```
138
-
139
- The above demo runs a reference implementation of pre-processing, model
140
- inference, and post processing.
141
-
142
- **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
143
- environment, please add the following to your cell (instead of the above).
144
- ```
145
- %run -m qai_hub_models.models.vit.demo
146
- ```
147
-
148
-
149
- ### Run model on a cloud-hosted device
150
-
151
- In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
152
- device. This script does the following:
153
- * Performance check on-device on a cloud-hosted device
154
- * Downloads compiled assets that can be deployed on-device for Android.
155
- * Accuracy check between PyTorch and on-device outputs.
156
-
157
- ```bash
158
- python -m qai_hub_models.models.vit.export
159
- ```
160
-
161
-
162
-
163
- ## How does this work?
164
-
165
- This [export script](https://aihub.qualcomm.com/models/vit/qai_hub_models/models/VIT/export.py)
166
- leverages [Qualcomm® AI Hub](https://aihub.qualcomm.com/) to optimize, validate, and deploy this model
167
- on-device. Lets go through each step below in detail:
168
-
169
- Step 1: **Compile model for on-device deployment**
170
-
171
- To compile a PyTorch model for on-device deployment, we first trace the model
172
- in memory using the `jit.trace` and then call the `submit_compile_job` API.
173
-
174
- ```python
175
- import torch
176
-
177
- import qai_hub as hub
178
- from qai_hub_models.models.vit import Model
179
-
180
- # Load the model
181
- torch_model = Model.from_pretrained()
182
-
183
- # Device
184
- device = hub.Device("Samsung Galaxy S25")
185
-
186
- # Trace model
187
- input_shape = torch_model.get_input_spec()
188
- sample_inputs = torch_model.sample_inputs()
189
-
190
- pt_model = torch.jit.trace(torch_model, [torch.tensor(data[0]) for _, data in sample_inputs.items()])
191
-
192
- # Compile model on a specific device
193
- compile_job = hub.submit_compile_job(
194
- model=pt_model,
195
- device=device,
196
- input_specs=torch_model.get_input_spec(),
197
- )
198
-
199
- # Get target model to run on-device
200
- target_model = compile_job.get_target_model()
201
-
202
- ```
203
-
204
-
205
- Step 2: **Performance profiling on cloud-hosted device**
206
-
207
- After compiling models from step 1. Models can be profiled model on-device using the
208
- `target_model`. Note that this scripts runs the model on a device automatically
209
- provisioned in the cloud. Once the job is submitted, you can navigate to a
210
- provided job URL to view a variety of on-device performance metrics.
211
- ```python
212
- profile_job = hub.submit_profile_job(
213
- model=target_model,
214
- device=device,
215
- )
216
-
217
- ```
218
-
219
- Step 3: **Verify on-device accuracy**
220
-
221
- To verify the accuracy of the model on-device, you can run on-device inference
222
- on sample input data on the same cloud hosted device.
223
- ```python
224
- input_data = torch_model.sample_inputs()
225
- inference_job = hub.submit_inference_job(
226
- model=target_model,
227
- device=device,
228
- inputs=input_data,
229
- )
230
- on_device_output = inference_job.download_output_data()
231
-
232
- ```
233
- With the output of the model, you can compute like PSNR, relative errors or
234
- spot check the output with expected output.
235
-
236
- **Note**: This on-device profiling and inference requires access to Qualcomm®
237
- AI Hub Workbench. [Sign up for access](https://myaccount.qualcomm.com/signup).
238
-
239
-
240
-
241
- ## Run demo on a cloud-hosted device
242
-
243
- You can also run the demo on-device.
244
-
245
- ```bash
246
- python -m qai_hub_models.models.vit.demo --eval-mode on-device
247
- ```
248
-
249
- **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
250
- environment, please add the following to your cell (instead of the above).
251
- ```
252
- %run -m qai_hub_models.models.vit.demo -- --eval-mode on-device
253
- ```
254
-
255
-
256
- ## Deploying compiled model to Android
257
-
258
-
259
- The models can be deployed using multiple runtimes:
260
- - TensorFlow Lite (`.tflite` export): [This
261
- tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
262
- guide to deploy the .tflite model in an Android application.
263
-
264
-
265
- - QNN (`.so` export ): This [sample
266
- app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
267
- provides instructions on how to use the `.so` shared library in an Android application.
268
-
269
-
270
- ## View on Qualcomm® AI Hub
271
- Get more details on VIT's performance across various devices [here](https://aihub.qualcomm.com/models/vit).
272
- Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
273
-
274
 
275
  ## License
276
  * The license for the original implementation of VIT can be found
277
  [here](https://github.com/pytorch/vision/blob/main/LICENSE).
278
 
279
-
280
-
281
  ## References
282
  * [An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale](https://arxiv.org/abs/2010.11929)
283
  * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/vision_transformer.py)
284
 
285
-
286
-
287
  ## Community
288
  * Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
289
  * For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
290
-
291
-
 
10
 
11
  ![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/vit/web-assets/model_demo.png)
12
 
13
+ # VIT: Optimized for Qualcomm Devices
 
 
14
 
15
  VIT is a machine learning model that can classify images from the Imagenet dataset. It can also be used as a backbone in building more complex models for specific use cases.
16
 
17
+ This is based on the implementation of VIT found [here](https://github.com/pytorch/vision/blob/main/torchvision/models/vision_transformer.py).
18
+ This repository contains pre-exported model files optimized for Qualcomm® devices. You can use the [Qualcomm® AI Hub Models](https://github.com/quic/ai-hub-models/blob/main/qai_hub_models/models/vit) library to export with custom configurations. More details on model performance across various devices, can be found [here](#performance-summary).
19
+
20
+ Qualcomm AI Hub Models uses [Qualcomm AI Hub Workbench](https://workbench.aihub.qualcomm.com) to compile, profile, and evaluate this model. [Sign up](https://myaccount.qualcomm.com/signup) to run these models on a hosted Qualcomm® device.
21
+
22
+ ## Getting Started
23
+ There are two ways to deploy this model on your device:
24
+
25
+ ### Option 1: Download Pre-Exported Models
26
+
27
+ Below are pre-exported model assets ready for deployment.
28
+
29
+ | Runtime | Precision | Chipset | SDK Versions | Download |
30
+ |---|---|---|---|---|
31
+ | ONNX | float | Universal | QAIRT 2.37, ONNX Runtime 1.23.0 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/vit/releases/v0.46.1/vit-onnx-float.zip)
32
+ | ONNX | w8a16 | Universal | QAIRT 2.37, ONNX Runtime 1.23.0 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/vit/releases/v0.46.1/vit-onnx-w8a16.zip)
33
+ | ONNX | w8a8 | Universal | QAIRT 2.37, ONNX Runtime 1.23.0 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/vit/releases/v0.46.1/vit-onnx-w8a8.zip)
34
+ | ONNX | w8a8_mixed_int16 | Universal | QAIRT 2.37, ONNX Runtime 1.23.0 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/vit/releases/v0.46.1/vit-onnx-w8a8_mixed_int16.zip)
35
+ | QNN_DLC | float | Universal | QAIRT 2.42 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/vit/releases/v0.46.1/vit-qnn_dlc-float.zip)
36
+ | QNN_DLC | w8a16 | Universal | QAIRT 2.42 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/vit/releases/v0.46.1/vit-qnn_dlc-w8a16.zip)
37
+ | QNN_DLC | w8a8 | Universal | QAIRT 2.42 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/vit/releases/v0.46.1/vit-qnn_dlc-w8a8.zip)
38
+ | TFLITE | float | Universal | QAIRT 2.42, TFLite 2.17.0 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/vit/releases/v0.46.1/vit-tflite-float.zip)
39
+ | TFLITE | w8a8 | Universal | QAIRT 2.42, TFLite 2.17.0 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/vit/releases/v0.46.1/vit-tflite-w8a8.zip)
40
+
41
+ For more device-specific assets and performance metrics, visit **[VIT on Qualcomm® AI Hub](https://aihub.qualcomm.com/models/vit)**.
42
+
43
+
44
+ ### Option 2: Export with Custom Configurations
45
+
46
+ Use the [Qualcomm® AI Hub Models](https://github.com/quic/ai-hub-models/blob/main/qai_hub_models/models/vit) Python library to compile and export the model with your own:
47
+ - Custom weights (e.g., fine-tuned checkpoints)
48
+ - Custom input shapes
49
+ - Target device and runtime configurations
50
+
51
+ This option is ideal if you need to customize the model beyond the default configuration provided here.
52
+
53
+ See our repository for [VIT on GitHub](https://github.com/quic/ai-hub-models/blob/main/qai_hub_models/models/vit) for usage instructions.
54
+
55
+ ## Model Details
56
+
57
+ **Model Type:** Model_use_case.image_classification
58
+
59
+ **Model Stats:**
60
+ - Model checkpoint: Imagenet
61
+ - Input resolution: 224x224
62
+ - Number of parameters: 86.6M
63
+ - Model size (float): 330 MB
64
+ - Model size (w8a16): 86.2 MB
65
+ - Model size (w8a8): 83.2 MB
66
+
67
+ ## Performance Summary
68
+ | Model | Runtime | Precision | Chipset | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit
69
+ |---|---|---|---|---|---|---
70
+ | VIT | ONNX | float | Snapdragon® X Elite | 13.861 ms | 171 - 171 MB | NPU
71
+ | VIT | ONNX | float | Snapdragon® 8 Gen 3 Mobile | 9.059 ms | 1 - 476 MB | NPU
72
+ | VIT | ONNX | float | Qualcomm® QCS8550 (Proxy) | 13.228 ms | 0 - 194 MB | NPU
73
+ | VIT | ONNX | float | Qualcomm® QCS9075 | 17.552 ms | 0 - 4 MB | NPU
74
+ | VIT | ONNX | float | Snapdragon® 8 Elite For Galaxy Mobile | 6.352 ms | 1 - 423 MB | NPU
75
+ | VIT | ONNX | float | Snapdragon® 8 Elite Gen 5 Mobile | 4.841 ms | 0 - 417 MB | NPU
76
+ | VIT | ONNX | w8a16 | Snapdragon® X Elite | 153.036 ms | 71 - 71 MB | NPU
77
+ | VIT | ONNX | w8a16 | Snapdragon® 8 Gen 3 Mobile | 228.999 ms | 61 - 308 MB | NPU
78
+ | VIT | ONNX | w8a16 | Qualcomm® QCS6490 | 1108.299 ms | 46 - 74 MB | CPU
79
+ | VIT | ONNX | w8a16 | Qualcomm® QCS8550 (Proxy) | 273.019 ms | 56 - 59 MB | NPU
80
+ | VIT | ONNX | w8a16 | Qualcomm® QCS9075 | 244.227 ms | 65 - 67 MB | NPU
81
+ | VIT | ONNX | w8a16 | Qualcomm® QCM6690 | 622.471 ms | 89 - 107 MB | CPU
82
+ | VIT | ONNX | w8a16 | Snapdragon® 8 Elite For Galaxy Mobile | 199.067 ms | 61 - 218 MB | NPU
83
+ | VIT | ONNX | w8a16 | Snapdragon® 7 Gen 4 Mobile | 593.838 ms | 53 - 68 MB | CPU
84
+ | VIT | ONNX | w8a16 | Snapdragon® 8 Elite Gen 5 Mobile | 183.415 ms | 57 - 218 MB | NPU
85
+ | VIT | ONNX | w8a8 | Snapdragon® X Elite | 141.184 ms | 69 - 69 MB | NPU
86
+ | VIT | ONNX | w8a8 | Snapdragon® 8 Gen 3 Mobile | 226.057 ms | 27 - 244 MB | NPU
87
+ | VIT | ONNX | w8a8 | Qualcomm® QCS6490 | 872.087 ms | 66 - 101 MB | CPU
88
+ | VIT | ONNX | w8a8 | Qualcomm® QCS8550 (Proxy) | 258.475 ms | 54 - 57 MB | NPU
89
+ | VIT | ONNX | w8a8 | Qualcomm® QCS9075 | 237.249 ms | 60 - 63 MB | NPU
90
+ | VIT | ONNX | w8a8 | Qualcomm® QCM6690 | 481.693 ms | 36 - 53 MB | CPU
91
+ | VIT | ONNX | w8a8 | Snapdragon® 8 Elite For Galaxy Mobile | 198.772 ms | 42 - 187 MB | NPU
92
+ | VIT | ONNX | w8a8 | Snapdragon® 7 Gen 4 Mobile | 462.71 ms | 59 - 78 MB | CPU
93
+ | VIT | ONNX | w8a8 | Snapdragon® 8 Elite Gen 5 Mobile | 180.511 ms | 60 - 211 MB | NPU
94
+ | VIT | ONNX | w8a8_mixed_int16 | Snapdragon® X Elite | 287.294 ms | 137 - 137 MB | NPU
95
+ | VIT | ONNX | w8a8_mixed_int16 | Snapdragon® 8 Gen 3 Mobile | 285.898 ms | 80 - 327 MB | NPU
96
+ | VIT | ONNX | w8a8_mixed_int16 | Qualcomm® QCS6490 | 902.655 ms | 44 - 82 MB | CPU
97
+ | VIT | ONNX | w8a8_mixed_int16 | Qualcomm® QCS8550 (Proxy) | 335.64 ms | 53 - 79 MB | NPU
98
+ | VIT | ONNX | w8a8_mixed_int16 | Qualcomm® QCS9075 | 330.457 ms | 79 - 82 MB | NPU
99
+ | VIT | ONNX | w8a8_mixed_int16 | Qualcomm® QCM6690 | 505.935 ms | 86 - 106 MB | CPU
100
+ | VIT | ONNX | w8a8_mixed_int16 | Snapdragon® 8 Elite For Galaxy Mobile | 246.071 ms | 79 - 239 MB | NPU
101
+ | VIT | ONNX | w8a8_mixed_int16 | Snapdragon® 7 Gen 4 Mobile | 487.306 ms | 52 - 69 MB | CPU
102
+ | VIT | ONNX | w8a8_mixed_int16 | Snapdragon® 8 Elite Gen 5 Mobile | 229.271 ms | 75 - 239 MB | NPU
103
+ | VIT | QNN_DLC | float | Snapdragon® X Elite | 11.827 ms | 1 - 1 MB | NPU
104
+ | VIT | QNN_DLC | float | Snapdragon® 8 Gen 3 Mobile | 7.671 ms | 0 - 362 MB | NPU
105
+ | VIT | QNN_DLC | float | Qualcomm® QCS8275 (Proxy) | 40.093 ms | 1 - 333 MB | NPU
106
+ | VIT | QNN_DLC | float | Qualcomm® QCS8550 (Proxy) | 11.114 ms | 1 - 3 MB | NPU
107
+ | VIT | QNN_DLC | float | Qualcomm® SA8775P | 13.774 ms | 1 - 327 MB | NPU
108
+ | VIT | QNN_DLC | float | Qualcomm® QCS9075 | 15.514 ms | 1 - 3 MB | NPU
109
+ | VIT | QNN_DLC | float | Qualcomm® QCS8450 (Proxy) | 19.081 ms | 0 - 351 MB | NPU
110
+ | VIT | QNN_DLC | float | Qualcomm® SA7255P | 40.093 ms | 1 - 333 MB | NPU
111
+ | VIT | QNN_DLC | float | Qualcomm® SA8295P | 17.032 ms | 1 - 334 MB | NPU
112
+ | VIT | QNN_DLC | float | Snapdragon® 8 Elite For Galaxy Mobile | 5.3 ms | 0 - 339 MB | NPU
113
+ | VIT | QNN_DLC | float | Snapdragon® 8 Elite Gen 5 Mobile | 4.083 ms | 1 - 348 MB | NPU
114
+ | VIT | TFLITE | float | Snapdragon® 8 Gen 3 Mobile | 5.901 ms | 0 - 323 MB | NPU
115
+ | VIT | TFLITE | float | Qualcomm® QCS8275 (Proxy) | 627.572 ms | 5 - 49 MB | CPU
116
+ | VIT | TFLITE | float | Qualcomm® QCS8550 (Proxy) | 7.96 ms | 0 - 3 MB | NPU
117
+ | VIT | TFLITE | float | Qualcomm® SA8775P | 11.092 ms | 0 - 294 MB | NPU
118
+ | VIT | TFLITE | float | Qualcomm® QCS9075 | 11.74 ms | 0 - 174 MB | NPU
119
+ | VIT | TFLITE | float | Qualcomm® QCS8450 (Proxy) | 13.901 ms | 0 - 293 MB | NPU
120
+ | VIT | TFLITE | float | Qualcomm® SA7255P | 627.572 ms | 5 - 49 MB | CPU
121
+ | VIT | TFLITE | float | Qualcomm® SA8295P | 13.38 ms | 0 - 268 MB | NPU
122
+ | VIT | TFLITE | float | Snapdragon® 8 Elite For Galaxy Mobile | 3.943 ms | 0 - 296 MB | NPU
123
+ | VIT | TFLITE | float | Snapdragon® 8 Elite Gen 5 Mobile | 3.032 ms | 0 - 299 MB | NPU
124
+ | VIT | TFLITE | w8a8 | Snapdragon® 8 Gen 3 Mobile | 4.707 ms | 0 - 189 MB | NPU
125
+ | VIT | TFLITE | w8a8 | Qualcomm® QCS6490 | 57.7 ms | 1 - 99 MB | NPU
126
+ | VIT | TFLITE | w8a8 | Qualcomm® QCS8275 (Proxy) | 14.295 ms | 0 - 90 MB | NPU
127
+ | VIT | TFLITE | w8a8 | Qualcomm® QCS8550 (Proxy) | 6.762 ms | 0 - 3 MB | NPU
128
+ | VIT | TFLITE | w8a8 | Qualcomm® SA8775P | 7.055 ms | 0 - 91 MB | NPU
129
+ | VIT | TFLITE | w8a8 | Qualcomm® QCS9075 | 7.592 ms | 0 - 89 MB | NPU
130
+ | VIT | TFLITE | w8a8 | Qualcomm® QCM6690 | 94.904 ms | 1 - 184 MB | NPU
131
+ | VIT | TFLITE | w8a8 | Qualcomm® QCS8450 (Proxy) | 8.851 ms | 0 - 185 MB | NPU
132
+ | VIT | TFLITE | w8a8 | Qualcomm® SA7255P | 14.295 ms | 0 - 90 MB | NPU
133
+ | VIT | TFLITE | w8a8 | Qualcomm® SA8295P | 9.698 ms | 0 - 93 MB | NPU
134
+ | VIT | TFLITE | w8a8 | Snapdragon® 8 Elite For Galaxy Mobile | 3.365 ms | 0 - 90 MB | NPU
135
+ | VIT | TFLITE | w8a8 | Snapdragon® 7 Gen 4 Mobile | 20.194 ms | 1 - 71 MB | NPU
136
+ | VIT | TFLITE | w8a8 | Snapdragon® 8 Elite Gen 5 Mobile | 2.273 ms | 0 - 95 MB | NPU
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
 
138
  ## License
139
  * The license for the original implementation of VIT can be found
140
  [here](https://github.com/pytorch/vision/blob/main/LICENSE).
141
 
 
 
142
  ## References
143
  * [An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale](https://arxiv.org/abs/2010.11929)
144
  * [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/vision_transformer.py)
145
 
 
 
146
  ## Community
147
  * Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
148
  * For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
 
 
VIT_float.dlc DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:f4a4eb6a306d2ee2ab3644d5b75e2bb499b75f8f532cdbb79c1a9594e160b9d1
3
- size 347073500
 
 
 
 
VIT_float.onnx.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:5d8bc7ebb753c1e6b957eae4560250ef9645b692bb5c0e82dd0d967388ad1f38
3
- size 322932422
 
 
 
 
VIT_float.tflite DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:f439e0beac21be4f246a4cab663049d6375cc4ff81fd43bde69f088b7e5c95cc
3
- size 346548920
 
 
 
 
VIT_w8a16.onnx.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:3d6dc3be1b12ea84291bb4e54390e3eba45bca47d30c61b2072efa46635e89f2
3
- size 304747638
 
 
 
 
VIT_w8a8.onnx.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9227bf4d1129365896202bfc47d4e405f23bba7874e2e3d36f0c070b2ab0840f
3
- size 304833031
 
 
 
 
VIT_w8a8.tflite DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:624d082f758e899535eb9245c7b9f9140261ef22ec5f9477b8f98f78f3d92ace
3
- size 87228000
 
 
 
 
VIT_w8a8_mixed_int16.onnx.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:80ad094529409b2935dec4f8412d7192bdd1d3c0de6a3409e88066b9244f8860
3
- size 307400857
 
 
 
 
tool-versions.yaml DELETED
@@ -1,4 +0,0 @@
1
- tool_versions:
2
- onnx:
3
- qairt: 2.37.1.250807093845_124904
4
- onnx_runtime: 1.23.0