qaihm-bot commited on
Commit
4126fd7
·
verified ·
1 Parent(s): 0851a5d

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

README.md CHANGED
@@ -10,276 +10,128 @@ pipeline_tag: image-segmentation
10
 
11
  ![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/segformer_base/web-assets/model_demo.png)
12
 
13
- # Segformer-Base: Optimized for Mobile Deployment
14
- ## Real-time object segmentation
15
-
16
 
17
  Segformer Base is a machine learning model that predicts masks and classes of objects in an image.
18
 
19
- This model is an implementation of Segformer-Base found [here](https://github.com/huggingface/transformers/tree/main/src/transformers/models/segformer).
20
-
21
-
22
- This repository provides scripts to run Segformer-Base on Qualcomm® devices.
23
- More details on model performance across various devices, can be found
24
- [here](https://aihub.qualcomm.com/models/segformer_base).
25
-
26
-
27
-
28
- ### Model Details
29
-
30
- - **Model Type:** Model_use_case.semantic_segmentation
31
- - **Model Stats:**
32
- - Model checkpoint: nvidia/segformer-b0-finetuned-ade-512-512
33
- - Input resolution: 512x512
34
- - Number of output classes: 150
35
- - Number of parameters: 3.75M
36
- - Model size (float): 14.4 MB
37
- - Model size (w8a16): 4.57 MB
38
- - Model size (w8a8): 3.90 MB
39
-
40
- | Model | Precision | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit | Target Model
41
- |---|---|---|---|---|---|---|---|---|
42
- | Segformer-Base | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | TFLITE | 212.895 ms | 9 - 166 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.tflite) |
43
- | Segformer-Base | float | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | QNN_DLC | 212.792 ms | 1 - 158 MB | NPU | [Segformer-Base.dlc](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.dlc) |
44
- | Segformer-Base | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | TFLITE | 123.547 ms | 10 - 210 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.tflite) |
45
- | Segformer-Base | float | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | QNN_DLC | 123.575 ms | 3 - 203 MB | NPU | [Segformer-Base.dlc](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.dlc) |
46
- | Segformer-Base | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | TFLITE | 109.256 ms | 10 - 12 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.tflite) |
47
- | Segformer-Base | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | QNN_DLC | 109.663 ms | 3 - 5 MB | NPU | [Segformer-Base.dlc](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.dlc) |
48
- | Segformer-Base | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | ONNX | 108.66 ms | 19 - 28 MB | NPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.onnx.zip) |
49
- | Segformer-Base | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | TFLITE | 111.372 ms | 9 - 166 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.tflite) |
50
- | Segformer-Base | float | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | QNN_DLC | 516.664 ms | 1 - 157 MB | NPU | [Segformer-Base.dlc](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.dlc) |
51
- | Segformer-Base | float | SA7255P ADP | Qualcomm® SA7255P | TFLITE | 212.895 ms | 9 - 166 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.tflite) |
52
- | Segformer-Base | float | SA7255P ADP | Qualcomm® SA7255P | QNN_DLC | 212.792 ms | 1 - 158 MB | NPU | [Segformer-Base.dlc](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.dlc) |
53
- | Segformer-Base | float | SA8295P ADP | Qualcomm® SA8295P | TFLITE | 125.11 ms | 9 - 172 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.tflite) |
54
- | Segformer-Base | float | SA8295P ADP | Qualcomm® SA8295P | QNN_DLC | 125.031 ms | 0 - 163 MB | NPU | [Segformer-Base.dlc](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.dlc) |
55
- | Segformer-Base | float | SA8775P ADP | Qualcomm® SA8775P | TFLITE | 111.372 ms | 9 - 166 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.tflite) |
56
- | Segformer-Base | float | SA8775P ADP | Qualcomm® SA8775P | QNN_DLC | 516.664 ms | 1 - 157 MB | NPU | [Segformer-Base.dlc](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.dlc) |
57
- | Segformer-Base | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | TFLITE | 83.718 ms | 8 - 208 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.tflite) |
58
- | Segformer-Base | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | QNN_DLC | 83.866 ms | 3 - 205 MB | NPU | [Segformer-Base.dlc](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.dlc) |
59
- | Segformer-Base | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | ONNX | 83.68 ms | 27 - 206 MB | NPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.onnx.zip) |
60
- | Segformer-Base | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | TFLITE | 74.648 ms | 9 - 174 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.tflite) |
61
- | Segformer-Base | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | QNN_DLC | 74.878 ms | 3 - 167 MB | NPU | [Segformer-Base.dlc](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.dlc) |
62
- | Segformer-Base | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | ONNX | 74.659 ms | 20 - 161 MB | NPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.onnx.zip) |
63
- | Segformer-Base | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | TFLITE | 73.639 ms | 8 - 172 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.tflite) |
64
- | Segformer-Base | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | QNN_DLC | 73.745 ms | 3 - 167 MB | NPU | [Segformer-Base.dlc](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.dlc) |
65
- | Segformer-Base | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | ONNX | 74.457 ms | 24 - 170 MB | NPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.onnx.zip) |
66
- | Segformer-Base | float | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN_DLC | 113.886 ms | 3 - 3 MB | NPU | [Segformer-Base.dlc](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.dlc) |
67
- | Segformer-Base | float | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 112.87 ms | 33 - 33 MB | NPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base.onnx.zip) |
68
- | Segformer-Base | w8a16 | Dragonwing Q-6690 MTP | Qualcomm® QCM6690 | ONNX | 490.192 ms | 361 - 378 MB | CPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a16.onnx.zip) |
69
- | Segformer-Base | w8a16 | Dragonwing RB3 Gen 2 Vision Kit | Qualcomm® QCS6490 | ONNX | 829.11 ms | 379 - 385 MB | CPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a16.onnx.zip) |
70
- | Segformer-Base | w8a16 | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | ONNX | 61.739 ms | 88 - 90 MB | NPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a16.onnx.zip) |
71
- | Segformer-Base | w8a16 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | ONNX | 49.337 ms | 89 - 274 MB | NPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a16.onnx.zip) |
72
- | Segformer-Base | w8a16 | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | ONNX | 45.932 ms | 89 - 226 MB | NPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a16.onnx.zip) |
73
- | Segformer-Base | w8a16 | Snapdragon 7 Gen 4 QRD | Snapdragon® 7 Gen 4 Mobile | ONNX | 412.126 ms | 355 - 374 MB | CPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a16.onnx.zip) |
74
- | Segformer-Base | w8a16 | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | ONNX | 39.861 ms | 91 - 226 MB | NPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a16.onnx.zip) |
75
- | Segformer-Base | w8a16 | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 52.548 ms | 131 - 131 MB | NPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a16.onnx.zip) |
76
- | Segformer-Base | w8a8 | Dragonwing Q-6690 MTP | Qualcomm® QCM6690 | TFLITE | 145.585 ms | 15 - 165 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.tflite) |
77
- | Segformer-Base | w8a8 | Dragonwing Q-6690 MTP | Qualcomm® QCM6690 | ONNX | 207.965 ms | 201 - 217 MB | CPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.onnx.zip) |
78
- | Segformer-Base | w8a8 | Dragonwing RB3 Gen 2 Vision Kit | Qualcomm® QCS6490 | TFLITE | 146.328 ms | 13 - 48 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.tflite) |
79
- | Segformer-Base | w8a8 | Dragonwing RB3 Gen 2 Vision Kit | Qualcomm® QCS6490 | ONNX | 358.036 ms | 200 - 207 MB | CPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.onnx.zip) |
80
- | Segformer-Base | w8a8 | QCS8275 (Proxy) | Qualcomm® QCS8275 (Proxy) | TFLITE | 22.055 ms | 3 - 152 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.tflite) |
81
- | Segformer-Base | w8a8 | QCS8450 (Proxy) | Qualcomm® QCS8450 (Proxy) | TFLITE | 19.223 ms | 2 - 188 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.tflite) |
82
- | Segformer-Base | w8a8 | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | TFLITE | 13.076 ms | 2 - 5 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.tflite) |
83
- | Segformer-Base | w8a8 | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | ONNX | 52.539 ms | 48 - 53 MB | NPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.onnx.zip) |
84
- | Segformer-Base | w8a8 | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | TFLITE | 13.519 ms | 2 - 152 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.tflite) |
85
- | Segformer-Base | w8a8 | SA7255P ADP | Qualcomm® SA7255P | TFLITE | 22.055 ms | 3 - 152 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.tflite) |
86
- | Segformer-Base | w8a8 | SA8295P ADP | Qualcomm® SA8295P | TFLITE | 16.019 ms | 2 - 159 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.tflite) |
87
- | Segformer-Base | w8a8 | SA8775P ADP | Qualcomm® SA8775P | TFLITE | 13.519 ms | 2 - 152 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.tflite) |
88
- | Segformer-Base | w8a8 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | TFLITE | 9.05 ms | 2 - 189 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.tflite) |
89
- | Segformer-Base | w8a8 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | ONNX | 41.879 ms | 58 - 222 MB | NPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.onnx.zip) |
90
- | Segformer-Base | w8a8 | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | TFLITE | 7.706 ms | 2 - 158 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.tflite) |
91
- | Segformer-Base | w8a8 | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | ONNX | 40.541 ms | 58 - 184 MB | NPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.onnx.zip) |
92
- | Segformer-Base | w8a8 | Snapdragon 7 Gen 4 QRD | Snapdragon® 7 Gen 4 Mobile | TFLITE | 48.591 ms | 15 - 164 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.tflite) |
93
- | Segformer-Base | w8a8 | Snapdragon 7 Gen 4 QRD | Snapdragon® 7 Gen 4 Mobile | ONNX | 191.501 ms | 199 - 217 MB | CPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.onnx.zip) |
94
- | Segformer-Base | w8a8 | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | TFLITE | 6.625 ms | 1 - 154 MB | NPU | [Segformer-Base.tflite](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.tflite) |
95
- | Segformer-Base | w8a8 | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | ONNX | 37.306 ms | 57 - 185 MB | NPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.onnx.zip) |
96
- | Segformer-Base | w8a8 | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 44.969 ms | 65 - 65 MB | NPU | [Segformer-Base.onnx.zip](https://huggingface.co/qualcomm/Segformer-Base/blob/main/Segformer-Base_w8a8.onnx.zip) |
97
-
98
-
99
-
100
-
101
- ## Installation
102
-
103
-
104
- Install the package via pip:
105
- ```bash
106
- pip install qai-hub-models
107
- ```
108
-
109
-
110
- ## Configure Qualcomm® AI Hub Workbench to run this model on a cloud-hosted device
111
-
112
- Sign-in to [Qualcomm® AI Hub Workbench](https://workbench.aihub.qualcomm.com/) with your
113
- Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.
114
-
115
- With this API token, you can configure your client to run models on the cloud
116
- hosted devices.
117
- ```bash
118
- qai-hub configure --api_token API_TOKEN
119
- ```
120
- Navigate to [docs](https://workbench.aihub.qualcomm.com/docs/) for more information.
121
-
122
-
123
-
124
- ## Demo off target
125
-
126
- The package contains a simple end-to-end demo that downloads pre-trained
127
- weights and runs this model on a sample input.
128
-
129
- ```bash
130
- python -m qai_hub_models.models.segformer_base.demo
131
- ```
132
-
133
- The above demo runs a reference implementation of pre-processing, model
134
- inference, and post processing.
135
-
136
- **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
137
- environment, please add the following to your cell (instead of the above).
138
- ```
139
- %run -m qai_hub_models.models.segformer_base.demo
140
- ```
141
-
142
-
143
- ### Run model on a cloud-hosted device
144
-
145
- In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
146
- device. This script does the following:
147
- * Performance check on-device on a cloud-hosted device
148
- * Downloads compiled assets that can be deployed on-device for Android.
149
- * Accuracy check between PyTorch and on-device outputs.
150
-
151
- ```bash
152
- python -m qai_hub_models.models.segformer_base.export
153
- ```
154
-
155
-
156
-
157
- ## How does this work?
158
-
159
- This [export script](https://aihub.qualcomm.com/models/segformer_base/qai_hub_models/models/Segformer-Base/export.py)
160
- leverages [Qualcomm® AI Hub](https://aihub.qualcomm.com/) to optimize, validate, and deploy this model
161
- on-device. Lets go through each step below in detail:
162
-
163
- Step 1: **Compile model for on-device deployment**
164
-
165
- To compile a PyTorch model for on-device deployment, we first trace the model
166
- in memory using the `jit.trace` and then call the `submit_compile_job` API.
167
-
168
- ```python
169
- import torch
170
-
171
- import qai_hub as hub
172
- from qai_hub_models.models.segformer_base import Model
173
-
174
- # Load the model
175
- torch_model = Model.from_pretrained()
176
-
177
- # Device
178
- device = hub.Device("Samsung Galaxy S25")
179
-
180
- # Trace model
181
- input_shape = torch_model.get_input_spec()
182
- sample_inputs = torch_model.sample_inputs()
183
-
184
- pt_model = torch.jit.trace(torch_model, [torch.tensor(data[0]) for _, data in sample_inputs.items()])
185
-
186
- # Compile model on a specific device
187
- compile_job = hub.submit_compile_job(
188
- model=pt_model,
189
- device=device,
190
- input_specs=torch_model.get_input_spec(),
191
- )
192
-
193
- # Get target model to run on-device
194
- target_model = compile_job.get_target_model()
195
-
196
- ```
197
-
198
-
199
- Step 2: **Performance profiling on cloud-hosted device**
200
-
201
- After compiling models from step 1. Models can be profiled model on-device using the
202
- `target_model`. Note that this scripts runs the model on a device automatically
203
- provisioned in the cloud. Once the job is submitted, you can navigate to a
204
- provided job URL to view a variety of on-device performance metrics.
205
- ```python
206
- profile_job = hub.submit_profile_job(
207
- model=target_model,
208
- device=device,
209
- )
210
-
211
- ```
212
-
213
- Step 3: **Verify on-device accuracy**
214
-
215
- To verify the accuracy of the model on-device, you can run on-device inference
216
- on sample input data on the same cloud hosted device.
217
- ```python
218
- input_data = torch_model.sample_inputs()
219
- inference_job = hub.submit_inference_job(
220
- model=target_model,
221
- device=device,
222
- inputs=input_data,
223
- )
224
- on_device_output = inference_job.download_output_data()
225
-
226
- ```
227
- With the output of the model, you can compute like PSNR, relative errors or
228
- spot check the output with expected output.
229
-
230
- **Note**: This on-device profiling and inference requires access to Qualcomm®
231
- AI Hub Workbench. [Sign up for access](https://myaccount.qualcomm.com/signup).
232
-
233
-
234
-
235
- ## Run demo on a cloud-hosted device
236
-
237
- You can also run the demo on-device.
238
-
239
- ```bash
240
- python -m qai_hub_models.models.segformer_base.demo --eval-mode on-device
241
- ```
242
-
243
- **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
244
- environment, please add the following to your cell (instead of the above).
245
- ```
246
- %run -m qai_hub_models.models.segformer_base.demo -- --eval-mode on-device
247
- ```
248
-
249
-
250
- ## Deploying compiled model to Android
251
-
252
-
253
- The models can be deployed using multiple runtimes:
254
- - TensorFlow Lite (`.tflite` export): [This
255
- tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
256
- guide to deploy the .tflite model in an Android application.
257
-
258
-
259
- - QNN (`.so` export ): This [sample
260
- app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
261
- provides instructions on how to use the `.so` shared library in an Android application.
262
-
263
-
264
- ## View on Qualcomm® AI Hub
265
- Get more details on Segformer-Base's performance across various devices [here](https://aihub.qualcomm.com/models/segformer_base).
266
- Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
267
-
268
 
269
  ## License
270
  * The license for the original implementation of Segformer-Base can be found
271
  [here](https://github.com/huggingface/transformers/blob/main/LICENSE).
272
 
273
-
274
-
275
  ## References
276
  * [SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers](https://arxiv.org/abs/2105.15203)
277
  * [Source Model Implementation](https://github.com/huggingface/transformers/tree/main/src/transformers/models/segformer)
278
 
279
-
280
-
281
  ## Community
282
  * Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
283
  * For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
284
-
285
-
 
10
 
11
  ![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/segformer_base/web-assets/model_demo.png)
12
 
13
+ # Segformer-Base: Optimized for Qualcomm Devices
 
 
14
 
15
  Segformer Base is a machine learning model that predicts masks and classes of objects in an image.
16
 
17
+ This is based on the implementation of Segformer-Base found [here](https://github.com/huggingface/transformers/tree/main/src/transformers/models/segformer).
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/segformer_base) 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/segformer_base/releases/v0.46.1/segformer_base-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/segformer_base/releases/v0.46.1/segformer_base-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/segformer_base/releases/v0.46.1/segformer_base-onnx-w8a8.zip)
34
+ | QNN_DLC | float | Universal | QAIRT 2.42 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/segformer_base/releases/v0.46.1/segformer_base-qnn_dlc-float.zip)
35
+ | QNN_DLC | w8a16 | Universal | QAIRT 2.42 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/segformer_base/releases/v0.46.1/segformer_base-qnn_dlc-w8a16.zip)
36
+ | QNN_DLC | w8a8 | Universal | QAIRT 2.42 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/segformer_base/releases/v0.46.1/segformer_base-qnn_dlc-w8a8.zip)
37
+ | 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/segformer_base/releases/v0.46.1/segformer_base-tflite-float.zip)
38
+ | 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/segformer_base/releases/v0.46.1/segformer_base-tflite-w8a8.zip)
39
+
40
+ For more device-specific assets and performance metrics, visit **[Segformer-Base on Qualcomm® AI Hub](https://aihub.qualcomm.com/models/segformer_base)**.
41
+
42
+
43
+ ### Option 2: Export with Custom Configurations
44
+
45
+ Use the [Qualcomm® AI Hub Models](https://github.com/quic/ai-hub-models/blob/main/qai_hub_models/models/segformer_base) Python library to compile and export the model with your own:
46
+ - Custom weights (e.g., fine-tuned checkpoints)
47
+ - Custom input shapes
48
+ - Target device and runtime configurations
49
+
50
+ This option is ideal if you need to customize the model beyond the default configuration provided here.
51
+
52
+ See our repository for [Segformer-Base on GitHub](https://github.com/quic/ai-hub-models/blob/main/qai_hub_models/models/segformer_base) for usage instructions.
53
+
54
+ ## Model Details
55
+
56
+ **Model Type:** Model_use_case.semantic_segmentation
57
+
58
+ **Model Stats:**
59
+ - Model checkpoint: nvidia/segformer-b0-finetuned-ade-512-512
60
+ - Input resolution: 512x512
61
+ - Number of output classes: 150
62
+ - Number of parameters: 3.75M
63
+ - Model size (float): 14.4 MB
64
+ - Model size (w8a16): 4.57 MB
65
+ - Model size (w8a8): 3.90 MB
66
+
67
+ ## Performance Summary
68
+ | Model | Runtime | Precision | Chipset | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit
69
+ |---|---|---|---|---|---|---
70
+ | Segformer-Base | ONNX | float | Snapdragon® X Elite | 112.756 ms | 33 - 33 MB | NPU
71
+ | Segformer-Base | ONNX | float | Snapdragon® 8 Gen 3 Mobile | 84.305 ms | 24 - 201 MB | NPU
72
+ | Segformer-Base | ONNX | float | Qualcomm® QCS8550 (Proxy) | 108.769 ms | 19 - 28 MB | NPU
73
+ | Segformer-Base | ONNX | float | Qualcomm® QCS9075 | 120.239 ms | 23 - 26 MB | NPU
74
+ | Segformer-Base | ONNX | float | Snapdragon® 8 Elite For Galaxy Mobile | 74.648 ms | 21 - 160 MB | NPU
75
+ | Segformer-Base | ONNX | float | Snapdragon® 8 Elite Gen 5 Mobile | 73.716 ms | 27 - 175 MB | NPU
76
+ | Segformer-Base | ONNX | w8a16 | Snapdragon® X Elite | 51.865 ms | 131 - 131 MB | NPU
77
+ | Segformer-Base | ONNX | w8a16 | Snapdragon® 8 Gen 3 Mobile | 49.215 ms | 90 - 271 MB | NPU
78
+ | Segformer-Base | ONNX | w8a16 | Qualcomm® QCS6490 | 841.672 ms | 379 - 385 MB | CPU
79
+ | Segformer-Base | ONNX | w8a16 | Qualcomm® QCS8550 (Proxy) | 61.921 ms | 83 - 87 MB | NPU
80
+ | Segformer-Base | ONNX | w8a16 | Qualcomm® QCS9075 | 68.104 ms | 89 - 92 MB | NPU
81
+ | Segformer-Base | ONNX | w8a16 | Qualcomm® QCM6690 | 574.842 ms | 324 - 334 MB | CPU
82
+ | Segformer-Base | ONNX | w8a16 | Snapdragon® 8 Elite For Galaxy Mobile | 45.505 ms | 90 - 228 MB | NPU
83
+ | Segformer-Base | ONNX | w8a16 | Snapdragon® 7 Gen 4 Mobile | 412.489 ms | 323 - 333 MB | CPU
84
+ | Segformer-Base | ONNX | w8a16 | Snapdragon® 8 Elite Gen 5 Mobile | 39.672 ms | 90 - 227 MB | NPU
85
+ | Segformer-Base | ONNX | w8a8 | Snapdragon® 8 Gen 3 Mobile | 42.463 ms | 58 - 219 MB | NPU
86
+ | Segformer-Base | ONNX | w8a8 | Qualcomm® QCS6490 | 352.803 ms | 200 - 207 MB | CPU
87
+ | Segformer-Base | ONNX | w8a8 | Qualcomm® QCS8550 (Proxy) | 51.706 ms | 54 - 59 MB | NPU
88
+ | Segformer-Base | ONNX | w8a8 | Qualcomm® QCS9075 | 56.372 ms | 58 - 61 MB | NPU
89
+ | Segformer-Base | ONNX | w8a8 | Qualcomm® QCM6690 | 214.217 ms | 203 - 213 MB | CPU
90
+ | Segformer-Base | ONNX | w8a8 | Snapdragon® 8 Elite For Galaxy Mobile | 39.85 ms | 57 - 181 MB | NPU
91
+ | Segformer-Base | ONNX | w8a8 | Snapdragon® 7 Gen 4 Mobile | 191.097 ms | 201 - 211 MB | CPU
92
+ | Segformer-Base | ONNX | w8a8 | Snapdragon® 8 Elite Gen 5 Mobile | 34.78 ms | 58 - 187 MB | NPU
93
+ | Segformer-Base | QNN_DLC | float | Snapdragon® X Elite | 114.563 ms | 3 - 3 MB | NPU
94
+ | Segformer-Base | QNN_DLC | float | Snapdragon® 8 Gen 3 Mobile | 83.817 ms | 2 - 228 MB | NPU
95
+ | Segformer-Base | QNN_DLC | float | Qualcomm® QCS8275 (Proxy) | 214.645 ms | 1 - 183 MB | NPU
96
+ | Segformer-Base | QNN_DLC | float | Qualcomm® QCS8550 (Proxy) | 110.097 ms | 3 - 5 MB | NPU
97
+ | Segformer-Base | QNN_DLC | float | Qualcomm® SA8775P | 472.472 ms | 1 - 189 MB | NPU
98
+ | Segformer-Base | QNN_DLC | float | Qualcomm® QCS9075 | 113.605 ms | 3 - 17 MB | NPU
99
+ | Segformer-Base | QNN_DLC | float | Qualcomm® QCS8450 (Proxy) | 121.904 ms | 2 - 225 MB | NPU
100
+ | Segformer-Base | QNN_DLC | float | Qualcomm® SA7255P | 214.645 ms | 1 - 183 MB | NPU
101
+ | Segformer-Base | QNN_DLC | float | Qualcomm® SA8295P | 122.206 ms | 3 - 181 MB | NPU
102
+ | Segformer-Base | QNN_DLC | float | Snapdragon® 8 Elite For Galaxy Mobile | 75.008 ms | 3 - 197 MB | NPU
103
+ | Segformer-Base | QNN_DLC | float | Snapdragon® 8 Elite Gen 5 Mobile | 74.055 ms | 3 - 195 MB | NPU
104
+ | Segformer-Base | TFLITE | float | Snapdragon® 8 Gen 3 Mobile | 83.556 ms | 9 - 241 MB | NPU
105
+ | Segformer-Base | TFLITE | float | Qualcomm® QCS8275 (Proxy) | 172.201 ms | 10 - 39 MB | GPU
106
+ | Segformer-Base | TFLITE | float | Qualcomm® QCS8550 (Proxy) | 110.21 ms | 9 - 12 MB | NPU
107
+ | Segformer-Base | TFLITE | float | Qualcomm® SA8775P | 110.706 ms | 0 - 193 MB | NPU
108
+ | Segformer-Base | TFLITE | float | Qualcomm® QCS9075 | 114.107 ms | 8 - 30 MB | NPU
109
+ | Segformer-Base | TFLITE | float | Qualcomm® QCS8450 (Proxy) | 122.524 ms | 9 - 235 MB | NPU
110
+ | Segformer-Base | TFLITE | float | Qualcomm® SA7255P | 172.201 ms | 10 - 39 MB | GPU
111
+ | Segformer-Base | TFLITE | float | Qualcomm® SA8295P | 122.282 ms | 10 - 198 MB | NPU
112
+ | Segformer-Base | TFLITE | float | Snapdragon® 8 Elite For Galaxy Mobile | 74.86 ms | 9 - 198 MB | NPU
113
+ | Segformer-Base | TFLITE | float | Snapdragon® 8 Elite Gen 5 Mobile | 74.212 ms | 14 - 213 MB | NPU
114
+ | Segformer-Base | TFLITE | w8a8 | Snapdragon® 8 Gen 3 Mobile | 10.304 ms | 1 - 214 MB | NPU
115
+ | Segformer-Base | TFLITE | w8a8 | Qualcomm® QCS6490 | 134.981 ms | 13 - 48 MB | NPU
116
+ | Segformer-Base | TFLITE | w8a8 | Qualcomm® QCS8275 (Proxy) | 170.87 ms | 15 - 45 MB | GPU
117
+ | Segformer-Base | TFLITE | w8a8 | Qualcomm® QCS8550 (Proxy) | 14.171 ms | 2 - 5 MB | NPU
118
+ | Segformer-Base | TFLITE | w8a8 | Qualcomm® SA8775P | 14.948 ms | 2 - 180 MB | NPU
119
+ | Segformer-Base | TFLITE | w8a8 | Qualcomm® QCS9075 | 12.574 ms | 2 - 12 MB | NPU
120
+ | Segformer-Base | TFLITE | w8a8 | Qualcomm® QCM6690 | 148.583 ms | 13 - 190 MB | NPU
121
+ | Segformer-Base | TFLITE | w8a8 | Qualcomm® QCS8450 (Proxy) | 18.904 ms | 2 - 213 MB | NPU
122
+ | Segformer-Base | TFLITE | w8a8 | Qualcomm® SA7255P | 170.87 ms | 15 - 45 MB | GPU
123
+ | Segformer-Base | TFLITE | w8a8 | Qualcomm® SA8295P | 17.819 ms | 2 - 184 MB | NPU
124
+ | Segformer-Base | TFLITE | w8a8 | Snapdragon® 8 Elite For Galaxy Mobile | 7.856 ms | 2 - 173 MB | NPU
125
+ | Segformer-Base | TFLITE | w8a8 | Snapdragon® 8 Elite Gen 5 Mobile | 7.214 ms | 2 - 188 MB | NPU
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
 
127
  ## License
128
  * The license for the original implementation of Segformer-Base can be found
129
  [here](https://github.com/huggingface/transformers/blob/main/LICENSE).
130
 
 
 
131
  ## References
132
  * [SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers](https://arxiv.org/abs/2105.15203)
133
  * [Source Model Implementation](https://github.com/huggingface/transformers/tree/main/src/transformers/models/segformer)
134
 
 
 
135
  ## Community
136
  * Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
137
  * For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
 
 
Segformer-Base_float.dlc DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:18b6ee099f1ee048e78ddb5bcacff30586911fce5045d3f4e80960dbc55f2bab
3
- size 15339444
 
 
 
 
Segformer-Base_float.onnx.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:91f7eeaa7ca19c788d73328b2db09ed47e2ece444898f4f2034ffcf5a89b3281
3
- size 13994809
 
 
 
 
Segformer-Base_float.tflite DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:5b8422594eac5dfc10c970d954cf6b98f0f90e35810e720583d4980dd6fc1969
3
- size 15113552
 
 
 
 
Segformer-Base_w8a16.onnx.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:a8ca0575cb1312db5cf443d678a4764bfb9be18b121ca8a89d94b74d0a27086d
3
- size 10824759
 
 
 
 
Segformer-Base_w8a8.onnx.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:72ec200260c82878393aa9cdef70b3edf7dd52b39538cdc090b6c91820824e33
3
- size 10828356
 
 
 
 
Segformer-Base_w8a8.tflite DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:e3416ac8d28906d6024fdcc1d3b9519080d460c55d14c34aef95c9c091dce244
3
- size 4092896
 
 
 
 
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