qaihm-bot commited on
Commit
b3d006c
·
verified ·
1 Parent(s): 4b61ff4

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

Files changed (3) hide show
  1. HRNet-W48-OCR_float.onnx.zip +0 -3
  2. README.md +39 -179
  3. tool-versions.yaml +0 -4
HRNet-W48-OCR_float.onnx.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:8bb57bb42fb07409d3e51dfbf71d572c8e8e8da670b8ce19db9ef2f317d85de8
3
- size 263264360
 
 
 
 
README.md CHANGED
@@ -11,212 +11,72 @@ pipeline_tag: image-segmentation
11
 
12
  ![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/hrnet_w48_ocr/web-assets/model_demo.png)
13
 
14
- # HRNet-W48-OCR: Optimized for Mobile Deployment
15
- ## Semantic segmentation in higher resolution
16
-
17
 
18
  HRNet-W48-OCR is a machine learning model that can segment images from the Cityscape dataset. It has lightweight and hardware-efficient operations and thus delivers significant speedup on diverse hardware platforms
19
 
20
- This model is an implementation of HRNet-W48-OCR found [here](https://github.com/HRNet/HRNet-Semantic-Segmentation).
21
-
22
-
23
- This repository provides scripts to run HRNet-W48-OCR on Qualcomm® devices.
24
- More details on model performance across various devices, can be found
25
- [here](https://aihub.qualcomm.com/models/hrnet_w48_ocr).
26
-
27
-
28
-
29
- ### Model Details
30
-
31
- - **Model Type:** Model_use_case.semantic_segmentation
32
- - **Model Stats:**
33
- - Model checkpoint: hrnet_ocr_cs_8162_torch11.pth
34
- - Input resolution: 2048x1024
35
- - Number of output classes: 19
36
- - Number of parameters: 70.3M
37
- - Model size (float): 268 MB
38
- - Model size (w8a16): 70.3 MB
39
-
40
- | Model | Precision | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit | Target Model
41
- |---|---|---|---|---|---|---|---|---|
42
- | HRNet-W48-OCR | float | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | ONNX | 1213.662 ms | 0 - 168 MB | NPU | [HRNet-W48-OCR.onnx.zip](https://huggingface.co/qualcomm/HRNet-W48-OCR/blob/main/HRNet-W48-OCR.onnx.zip) |
43
- | HRNet-W48-OCR | float | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | ONNX | 854.428 ms | 25 - 3970 MB | NPU | [HRNet-W48-OCR.onnx.zip](https://huggingface.co/qualcomm/HRNet-W48-OCR/blob/main/HRNet-W48-OCR.onnx.zip) |
44
- | HRNet-W48-OCR | float | Samsung Galaxy S25 | Snapdragon® 8 Elite For Galaxy Mobile | ONNX | 741.79 ms | 12 - 2504 MB | NPU | [HRNet-W48-OCR.onnx.zip](https://huggingface.co/qualcomm/HRNet-W48-OCR/blob/main/HRNet-W48-OCR.onnx.zip) |
45
- | HRNet-W48-OCR | float | Snapdragon 8 Elite Gen 5 QRD | Snapdragon® 8 Elite Gen 5 Mobile | ONNX | 637.57 ms | 35 - 2596 MB | NPU | [HRNet-W48-OCR.onnx.zip](https://huggingface.co/qualcomm/HRNet-W48-OCR/blob/main/HRNet-W48-OCR.onnx.zip) |
46
- | HRNet-W48-OCR | float | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 989.637 ms | 150 - 150 MB | NPU | [HRNet-W48-OCR.onnx.zip](https://huggingface.co/qualcomm/HRNet-W48-OCR/blob/main/HRNet-W48-OCR.onnx.zip) |
47
-
48
-
49
-
50
-
51
- ## Installation
52
-
53
-
54
- Install the package via pip:
55
- ```bash
56
- # NOTE: 3.10 <= PYTHON_VERSION < 3.14 is supported.
57
- pip install "qai-hub-models[hrnet-w48-ocr]"
58
- ```
59
-
60
-
61
- ## Configure Qualcomm® AI Hub Workbench to run this model on a cloud-hosted device
62
-
63
- Sign-in to [Qualcomm® AI Hub Workbench](https://workbench.aihub.qualcomm.com/) with your
64
- Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.
65
-
66
- With this API token, you can configure your client to run models on the cloud
67
- hosted devices.
68
- ```bash
69
- qai-hub configure --api_token API_TOKEN
70
- ```
71
- Navigate to [docs](https://workbench.aihub.qualcomm.com/docs/) for more information.
72
-
73
-
74
-
75
- ## Demo off target
76
-
77
- The package contains a simple end-to-end demo that downloads pre-trained
78
- weights and runs this model on a sample input.
79
-
80
- ```bash
81
- python -m qai_hub_models.models.hrnet_w48_ocr.demo
82
- ```
83
-
84
- The above demo runs a reference implementation of pre-processing, model
85
- inference, and post processing.
86
-
87
- **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
88
- environment, please add the following to your cell (instead of the above).
89
- ```
90
- %run -m qai_hub_models.models.hrnet_w48_ocr.demo
91
- ```
92
-
93
-
94
- ### Run model on a cloud-hosted device
95
 
96
- In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
97
- device. This script does the following:
98
- * Performance check on-device on a cloud-hosted device
99
- * Downloads compiled assets that can be deployed on-device for Android.
100
- * Accuracy check between PyTorch and on-device outputs.
101
 
102
- ```bash
103
- python -m qai_hub_models.models.hrnet_w48_ocr.export
104
- ```
105
 
 
106
 
 
107
 
108
- ## How does this work?
 
 
 
 
109
 
110
- This [export script](https://aihub.qualcomm.com/models/hrnet_w48_ocr/qai_hub_models/models/HRNet-W48-OCR/export.py)
111
- leverages [Qualcomm® AI Hub](https://aihub.qualcomm.com/) to optimize, validate, and deploy this model
112
- on-device. Lets go through each step below in detail:
113
 
114
- Step 1: **Compile model for on-device deployment**
115
 
116
- To compile a PyTorch model for on-device deployment, we first trace the model
117
- in memory using the `jit.trace` and then call the `submit_compile_job` API.
118
 
119
- ```python
120
- import torch
 
 
121
 
122
- import qai_hub as hub
123
- from qai_hub_models.models.hrnet_w48_ocr import Model
124
 
125
- # Load the model
126
- torch_model = Model.from_pretrained()
127
 
128
- # Device
129
- device = hub.Device("Samsung Galaxy S25")
130
 
131
- # Trace model
132
- input_shape = torch_model.get_input_spec()
133
- sample_inputs = torch_model.sample_inputs()
134
 
135
- pt_model = torch.jit.trace(torch_model, [torch.tensor(data[0]) for _, data in sample_inputs.items()])
136
-
137
- # Compile model on a specific device
138
- compile_job = hub.submit_compile_job(
139
- model=pt_model,
140
- device=device,
141
- input_specs=torch_model.get_input_spec(),
142
- )
143
-
144
- # Get target model to run on-device
145
- target_model = compile_job.get_target_model()
146
-
147
- ```
148
-
149
-
150
- Step 2: **Performance profiling on cloud-hosted device**
151
-
152
- After compiling models from step 1. Models can be profiled model on-device using the
153
- `target_model`. Note that this scripts runs the model on a device automatically
154
- provisioned in the cloud. Once the job is submitted, you can navigate to a
155
- provided job URL to view a variety of on-device performance metrics.
156
- ```python
157
- profile_job = hub.submit_profile_job(
158
- model=target_model,
159
- device=device,
160
- )
161
-
162
- ```
163
-
164
- Step 3: **Verify on-device accuracy**
165
-
166
- To verify the accuracy of the model on-device, you can run on-device inference
167
- on sample input data on the same cloud hosted device.
168
- ```python
169
- input_data = torch_model.sample_inputs()
170
- inference_job = hub.submit_inference_job(
171
- model=target_model,
172
- device=device,
173
- inputs=input_data,
174
- )
175
- on_device_output = inference_job.download_output_data()
176
-
177
- ```
178
- With the output of the model, you can compute like PSNR, relative errors or
179
- spot check the output with expected output.
180
-
181
- **Note**: This on-device profiling and inference requires access to Qualcomm®
182
- AI Hub Workbench. [Sign up for access](https://myaccount.qualcomm.com/signup).
183
-
184
-
185
-
186
-
187
- ## Deploying compiled model to Android
188
-
189
-
190
- The models can be deployed using multiple runtimes:
191
- - TensorFlow Lite (`.tflite` export): [This
192
- tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
193
- guide to deploy the .tflite model in an Android application.
194
-
195
-
196
- - QNN (`.so` export ): This [sample
197
- app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
198
- provides instructions on how to use the `.so` shared library in an Android application.
199
-
200
-
201
- ## View on Qualcomm® AI Hub
202
- Get more details on HRNet-W48-OCR's performance across various devices [here](https://aihub.qualcomm.com/models/hrnet_w48_ocr).
203
- Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
204
 
 
 
 
 
 
 
 
 
 
205
 
206
  ## License
207
  * The license for the original implementation of HRNet-W48-OCR can be found
208
  [here](https://github.com/HRNet/HRNet-Semantic-Segmentation/blob/HRNet-OCR/LICENSE).
209
 
210
-
211
-
212
  ## References
213
  * [Segmentation Transformer: Object-Contextual Representations for Semantic Segmentation](https://arxiv.org/abs/1909.11065)
214
  * [Source Model Implementation](https://github.com/HRNet/HRNet-Semantic-Segmentation)
215
 
216
-
217
-
218
  ## Community
219
  * Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
220
  * For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
221
-
222
-
 
11
 
12
  ![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/hrnet_w48_ocr/web-assets/model_demo.png)
13
 
14
+ # HRNet-W48-OCR: Optimized for Qualcomm Devices
 
 
15
 
16
  HRNet-W48-OCR is a machine learning model that can segment images from the Cityscape dataset. It has lightweight and hardware-efficient operations and thus delivers significant speedup on diverse hardware platforms
17
 
18
+ This is based on the implementation of HRNet-W48-OCR found [here](https://github.com/HRNet/HRNet-Semantic-Segmentation).
19
+ 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/hrnet_w48_ocr) library to export with custom configurations. More details on model performance across various devices, can be found [here](#performance-summary).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
+ 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.
 
 
 
 
22
 
23
+ ## Getting Started
24
+ There are two ways to deploy this model on your device:
 
25
 
26
+ ### Option 1: Download Pre-Exported Models
27
 
28
+ Below are pre-exported model assets ready for deployment.
29
 
30
+ | Runtime | Precision | Chipset | SDK Versions | Download |
31
+ |---|---|---|---|---|
32
+ | 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/hrnet_w48_ocr/releases/v0.46.1/hrnet_w48_ocr-onnx-float.zip)
33
+ | QNN_DLC | w8a16 | Universal | QAIRT 2.42 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/hrnet_w48_ocr/releases/v0.46.1/hrnet_w48_ocr-qnn_dlc-w8a16.zip)
34
+ | TFLITE | float | Universal | TFLite 2.17.0 | [Download](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/hrnet_w48_ocr/releases/v0.46.1/hrnet_w48_ocr-tflite-float.zip)
35
 
36
+ For more device-specific assets and performance metrics, visit **[HRNet-W48-OCR on Qualcomm® AI Hub](https://aihub.qualcomm.com/models/hrnet_w48_ocr)**.
 
 
37
 
 
38
 
39
+ ### Option 2: Export with Custom Configurations
 
40
 
41
+ Use the [Qualcomm® AI Hub Models](https://github.com/quic/ai-hub-models/blob/main/qai_hub_models/models/hrnet_w48_ocr) Python library to compile and export the model with your own:
42
+ - Custom weights (e.g., fine-tuned checkpoints)
43
+ - Custom input shapes
44
+ - Target device and runtime configurations
45
 
46
+ This option is ideal if you need to customize the model beyond the default configuration provided here.
 
47
 
48
+ See our repository for [HRNet-W48-OCR on GitHub](https://github.com/quic/ai-hub-models/blob/main/qai_hub_models/models/hrnet_w48_ocr) for usage instructions.
 
49
 
50
+ ## Model Details
 
51
 
52
+ **Model Type:** Model_use_case.semantic_segmentation
 
 
53
 
54
+ **Model Stats:**
55
+ - Model checkpoint: hrnet_ocr_cs_8162_torch11.pth
56
+ - Input resolution: 2048x1024
57
+ - Number of output classes: 19
58
+ - Number of parameters: 70.3M
59
+ - Model size (float): 268 MB
60
+ - Model size (w8a16): 70.3 MB
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
+ ## Performance Summary
63
+ | Model | Runtime | Precision | Chipset | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit
64
+ |---|---|---|---|---|---|---
65
+ | HRNet-W48-OCR | ONNX | float | Snapdragon® X Elite | 990.193 ms | 150 - 150 MB | NPU
66
+ | HRNet-W48-OCR | ONNX | float | Snapdragon® 8 Gen 3 Mobile | 868.977 ms | 36 - 3980 MB | NPU
67
+ | HRNet-W48-OCR | ONNX | float | Qualcomm® QCS8550 (Proxy) | 1168.136 ms | 24 - 28 MB | NPU
68
+ | HRNet-W48-OCR | ONNX | float | Qualcomm® QCS9075 | 1384.373 ms | 24 - 51 MB | NPU
69
+ | HRNet-W48-OCR | ONNX | float | Snapdragon® 8 Elite For Galaxy Mobile | 736.445 ms | 11 - 2506 MB | NPU
70
+ | HRNet-W48-OCR | ONNX | float | Snapdragon® 8 Elite Gen 5 Mobile | 651.912 ms | 37 - 2597 MB | NPU
71
 
72
  ## License
73
  * The license for the original implementation of HRNet-W48-OCR can be found
74
  [here](https://github.com/HRNet/HRNet-Semantic-Segmentation/blob/HRNet-OCR/LICENSE).
75
 
 
 
76
  ## References
77
  * [Segmentation Transformer: Object-Contextual Representations for Semantic Segmentation](https://arxiv.org/abs/1909.11065)
78
  * [Source Model Implementation](https://github.com/HRNet/HRNet-Semantic-Segmentation)
79
 
 
 
80
  ## Community
81
  * Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
82
  * For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
 
 
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