Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
@@ -19,7 +19,7 @@ tags:
|
|
19 |
|
20 |
ResNet50 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.
|
21 |
|
22 |
-
This model is an implementation of ResNet50Quantized found [here](
|
23 |
This repository provides scripts to run ResNet50Quantized on Qualcomm® devices.
|
24 |
More details on model performance across various devices, can be found
|
25 |
[here](https://aihub.qualcomm.com/models/resnet50_quantized).
|
@@ -34,26 +34,43 @@ More details on model performance across various devices, can be found
|
|
34 |
- Number of parameters: 25.5M
|
35 |
- Model size: 25.1 MB
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
|
39 |
|
40 |
-
| Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Precision | Primary Compute Unit | Target Model
|
41 |
-
| ---|---|---|---|---|---|---|---|
|
42 |
-
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | TFLite | 0.783 ms | 0 - 2 MB | INT8 | NPU | [ResNet50Quantized.tflite](https://huggingface.co/qualcomm/ResNet50Quantized/blob/main/ResNet50Quantized.tflite)
|
43 |
-
| Samsung Galaxy S23 Ultra (Android 13) | Snapdragon® 8 Gen 2 | QNN Model Library | 1.003 ms | 0 - 243 MB | INT8 | NPU | [ResNet50Quantized.so](https://huggingface.co/qualcomm/ResNet50Quantized/blob/main/ResNet50Quantized.so)
|
44 |
-
|
45 |
-
|
46 |
|
47 |
## Installation
|
48 |
|
49 |
This model can be installed as a Python package via pip.
|
50 |
|
51 |
```bash
|
52 |
-
pip install
|
53 |
```
|
54 |
|
55 |
|
56 |
-
|
57 |
## Configure Qualcomm® AI Hub to run this model on a cloud-hosted device
|
58 |
|
59 |
Sign-in to [Qualcomm® AI Hub](https://app.aihub.qualcomm.com/) with your
|
@@ -98,18 +115,78 @@ device. This script does the following:
|
|
98 |
```bash
|
99 |
python -m qai_hub_models.models.resnet50_quantized.export
|
100 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
```
|
103 |
-
Profile Job summary of ResNet50Quantized
|
104 |
-
--------------------------------------------------
|
105 |
-
Device: Snapdragon X Elite CRD (11)
|
106 |
-
Estimated Inference Time: 1.01 ms
|
107 |
-
Estimated Peak Memory Range: 0.41-0.41 MB
|
108 |
-
Compute Units: NPU (78) | Total (78)
|
109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
```
|
|
|
|
|
112 |
|
|
|
|
|
113 |
|
114 |
|
115 |
|
@@ -146,15 +223,19 @@ provides instructions on how to use the `.so` shared library in an Android appl
|
|
146 |
Get more details on ResNet50Quantized's performance across various devices [here](https://aihub.qualcomm.com/models/resnet50_quantized).
|
147 |
Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
|
148 |
|
|
|
149 |
## License
|
150 |
-
|
151 |
-
|
152 |
-
|
|
|
153 |
|
154 |
## References
|
155 |
* [Deep Residual Learning for Image Recognition](https://arxiv.org/abs/1512.03385)
|
156 |
* [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py)
|
157 |
|
|
|
|
|
158 |
## Community
|
159 |
* Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
|
160 |
* For questions or feedback please [reach out to us](mailto:[email protected]).
|
|
|
19 |
|
20 |
ResNet50 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.
|
21 |
|
22 |
+
This model is an implementation of ResNet50Quantized found [here]({source_repo}).
|
23 |
This repository provides scripts to run ResNet50Quantized on Qualcomm® devices.
|
24 |
More details on model performance across various devices, can be found
|
25 |
[here](https://aihub.qualcomm.com/models/resnet50_quantized).
|
|
|
34 |
- Number of parameters: 25.5M
|
35 |
- Model size: 25.1 MB
|
36 |
|
37 |
+
| Model | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Precision | Primary Compute Unit | Target Model
|
38 |
+
|---|---|---|---|---|---|---|---|---|
|
39 |
+
| ResNet50Quantized | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | TFLITE | 0.788 ms | 0 - 11 MB | INT8 | NPU | [ResNet50Quantized.tflite](https://huggingface.co/qualcomm/ResNet50Quantized/blob/main/ResNet50Quantized.tflite) |
|
40 |
+
| ResNet50Quantized | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | QNN | 1.001 ms | 0 - 32 MB | INT8 | NPU | [ResNet50Quantized.so](https://huggingface.co/qualcomm/ResNet50Quantized/blob/main/ResNet50Quantized.so) |
|
41 |
+
| ResNet50Quantized | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 | ONNX | 1.526 ms | 0 - 30 MB | INT8 | NPU | [ResNet50Quantized.onnx](https://huggingface.co/qualcomm/ResNet50Quantized/blob/main/ResNet50Quantized.onnx) |
|
42 |
+
| ResNet50Quantized | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | TFLITE | 0.584 ms | 0 - 63 MB | INT8 | NPU | [ResNet50Quantized.tflite](https://huggingface.co/qualcomm/ResNet50Quantized/blob/main/ResNet50Quantized.tflite) |
|
43 |
+
| ResNet50Quantized | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | QNN | 0.749 ms | 0 - 15 MB | INT8 | NPU | [ResNet50Quantized.so](https://huggingface.co/qualcomm/ResNet50Quantized/blob/main/ResNet50Quantized.so) |
|
44 |
+
| ResNet50Quantized | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 | ONNX | 1.128 ms | 0 - 93 MB | INT8 | NPU | [ResNet50Quantized.onnx](https://huggingface.co/qualcomm/ResNet50Quantized/blob/main/ResNet50Quantized.onnx) |
|
45 |
+
| ResNet50Quantized | RB3 Gen 2 (Proxy) | QCS6490 Proxy | TFLITE | 2.827 ms | 0 - 27 MB | INT8 | NPU | [ResNet50Quantized.tflite](https://huggingface.co/qualcomm/ResNet50Quantized/blob/main/ResNet50Quantized.tflite) |
|
46 |
+
| ResNet50Quantized | RB3 Gen 2 (Proxy) | QCS6490 Proxy | QNN | 4.072 ms | 0 - 8 MB | INT8 | NPU | Use Export Script |
|
47 |
+
| ResNet50Quantized | RB5 (Proxy) | QCS8250 Proxy | TFLITE | 11.444 ms | 0 - 7 MB | INT8 | NPU | [ResNet50Quantized.tflite](https://huggingface.co/qualcomm/ResNet50Quantized/blob/main/ResNet50Quantized.tflite) |
|
48 |
+
| ResNet50Quantized | QCS8550 (Proxy) | QCS8550 Proxy | TFLITE | 0.785 ms | 0 - 3 MB | INT8 | NPU | [ResNet50Quantized.tflite](https://huggingface.co/qualcomm/ResNet50Quantized/blob/main/ResNet50Quantized.tflite) |
|
49 |
+
| ResNet50Quantized | QCS8550 (Proxy) | QCS8550 Proxy | QNN | 0.943 ms | 0 - 1 MB | INT8 | NPU | Use Export Script |
|
50 |
+
| ResNet50Quantized | SA8255 (Proxy) | SA8255P Proxy | TFLITE | 0.782 ms | 0 - 15 MB | INT8 | NPU | [ResNet50Quantized.tflite](https://huggingface.co/qualcomm/ResNet50Quantized/blob/main/ResNet50Quantized.tflite) |
|
51 |
+
| ResNet50Quantized | SA8255 (Proxy) | SA8255P Proxy | QNN | 0.947 ms | 0 - 2 MB | INT8 | NPU | Use Export Script |
|
52 |
+
| ResNet50Quantized | SA8775 (Proxy) | SA8775P Proxy | TFLITE | 0.787 ms | 0 - 16 MB | INT8 | NPU | [ResNet50Quantized.tflite](https://huggingface.co/qualcomm/ResNet50Quantized/blob/main/ResNet50Quantized.tflite) |
|
53 |
+
| ResNet50Quantized | SA8775 (Proxy) | SA8775P Proxy | QNN | 0.948 ms | 0 - 2 MB | INT8 | NPU | Use Export Script |
|
54 |
+
| ResNet50Quantized | QCS8450 (Proxy) | QCS8450 Proxy | TFLITE | 0.909 ms | 0 - 64 MB | INT8 | NPU | [ResNet50Quantized.tflite](https://huggingface.co/qualcomm/ResNet50Quantized/blob/main/ResNet50Quantized.tflite) |
|
55 |
+
| ResNet50Quantized | QCS8450 (Proxy) | QCS8450 Proxy | QNN | 1.135 ms | 0 - 18 MB | INT8 | NPU | Use Export Script |
|
56 |
+
| ResNet50Quantized | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | TFLITE | 0.518 ms | 0 - 23 MB | INT8 | NPU | [ResNet50Quantized.tflite](https://huggingface.co/qualcomm/ResNet50Quantized/blob/main/ResNet50Quantized.tflite) |
|
57 |
+
| ResNet50Quantized | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | QNN | 0.693 ms | 0 - 17 MB | INT8 | NPU | Use Export Script |
|
58 |
+
| ResNet50Quantized | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite | ONNX | 0.918 ms | 0 - 39 MB | INT8 | NPU | [ResNet50Quantized.onnx](https://huggingface.co/qualcomm/ResNet50Quantized/blob/main/ResNet50Quantized.onnx) |
|
59 |
+
| ResNet50Quantized | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN | 1.009 ms | 0 - 0 MB | INT8 | NPU | Use Export Script |
|
60 |
+
| ResNet50Quantized | Snapdragon X Elite CRD | Snapdragon® X Elite | ONNX | 1.569 ms | 28 - 28 MB | INT8 | NPU | [ResNet50Quantized.onnx](https://huggingface.co/qualcomm/ResNet50Quantized/blob/main/ResNet50Quantized.onnx) |
|
61 |
|
62 |
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
## Installation
|
66 |
|
67 |
This model can be installed as a Python package via pip.
|
68 |
|
69 |
```bash
|
70 |
+
pip install qai-hub-models
|
71 |
```
|
72 |
|
73 |
|
|
|
74 |
## Configure Qualcomm® AI Hub to run this model on a cloud-hosted device
|
75 |
|
76 |
Sign-in to [Qualcomm® AI Hub](https://app.aihub.qualcomm.com/) with your
|
|
|
115 |
```bash
|
116 |
python -m qai_hub_models.models.resnet50_quantized.export
|
117 |
```
|
118 |
+
```
|
119 |
+
Profiling Results
|
120 |
+
------------------------------------------------------------
|
121 |
+
ResNet50Quantized
|
122 |
+
Device : Samsung Galaxy S23 (13)
|
123 |
+
Runtime : TFLITE
|
124 |
+
Estimated inference time (ms) : 0.8
|
125 |
+
Estimated peak memory usage (MB): [0, 11]
|
126 |
+
Total # Ops : 82
|
127 |
+
Compute Unit(s) : NPU (82 ops)
|
128 |
+
```
|
129 |
+
|
130 |
+
|
131 |
+
## How does this work?
|
132 |
+
|
133 |
+
This [export script](https://aihub.qualcomm.com/models/resnet50_quantized/qai_hub_models/models/ResNet50Quantized/export.py)
|
134 |
+
leverages [Qualcomm® AI Hub](https://aihub.qualcomm.com/) to optimize, validate, and deploy this model
|
135 |
+
on-device. Lets go through each step below in detail:
|
136 |
+
|
137 |
+
Step 1: **Compile model for on-device deployment**
|
138 |
+
|
139 |
+
To compile a PyTorch model for on-device deployment, we first trace the model
|
140 |
+
in memory using the `jit.trace` and then call the `submit_compile_job` API.
|
141 |
+
|
142 |
+
```python
|
143 |
+
import torch
|
144 |
+
|
145 |
+
import qai_hub as hub
|
146 |
+
from qai_hub_models.models.resnet50_quantized import
|
147 |
+
|
148 |
+
# Load the model
|
149 |
|
150 |
+
# Device
|
151 |
+
device = hub.Device("Samsung Galaxy S23")
|
152 |
+
|
153 |
+
|
154 |
+
```
|
155 |
+
|
156 |
+
|
157 |
+
Step 2: **Performance profiling on cloud-hosted device**
|
158 |
+
|
159 |
+
After compiling models from step 1. Models can be profiled model on-device using the
|
160 |
+
`target_model`. Note that this scripts runs the model on a device automatically
|
161 |
+
provisioned in the cloud. Once the job is submitted, you can navigate to a
|
162 |
+
provided job URL to view a variety of on-device performance metrics.
|
163 |
+
```python
|
164 |
+
profile_job = hub.submit_profile_job(
|
165 |
+
model=target_model,
|
166 |
+
device=device,
|
167 |
+
)
|
168 |
+
|
169 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
|
171 |
+
Step 3: **Verify on-device accuracy**
|
172 |
+
|
173 |
+
To verify the accuracy of the model on-device, you can run on-device inference
|
174 |
+
on sample input data on the same cloud hosted device.
|
175 |
+
```python
|
176 |
+
input_data = torch_model.sample_inputs()
|
177 |
+
inference_job = hub.submit_inference_job(
|
178 |
+
model=target_model,
|
179 |
+
device=device,
|
180 |
+
inputs=input_data,
|
181 |
+
)
|
182 |
+
on_device_output = inference_job.download_output_data()
|
183 |
|
184 |
```
|
185 |
+
With the output of the model, you can compute like PSNR, relative errors or
|
186 |
+
spot check the output with expected output.
|
187 |
|
188 |
+
**Note**: This on-device profiling and inference requires access to Qualcomm®
|
189 |
+
AI Hub. [Sign up for access](https://myaccount.qualcomm.com/signup).
|
190 |
|
191 |
|
192 |
|
|
|
223 |
Get more details on ResNet50Quantized's performance across various devices [here](https://aihub.qualcomm.com/models/resnet50_quantized).
|
224 |
Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
|
225 |
|
226 |
+
|
227 |
## License
|
228 |
+
* The license for the original implementation of ResNet50Quantized can be found [here](https://github.com/pytorch/vision/blob/main/LICENSE).
|
229 |
+
* The license for the compiled assets for on-device deployment can be found [here](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/Qualcomm+AI+Hub+Proprietary+License.pdf)
|
230 |
+
|
231 |
+
|
232 |
|
233 |
## References
|
234 |
* [Deep Residual Learning for Image Recognition](https://arxiv.org/abs/1512.03385)
|
235 |
* [Source Model Implementation](https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py)
|
236 |
|
237 |
+
|
238 |
+
|
239 |
## Community
|
240 |
* Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
|
241 |
* For questions or feedback please [reach out to us](mailto:[email protected]).
|