Upload README.md with huggingface_hub
Browse files
README.md
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
datasets:
|
3 |
+
- imagenet-1k
|
4 |
+
- imagenet-22k
|
5 |
+
library_name: pytorch
|
6 |
+
license: bsd-3-clause
|
7 |
+
pipeline_tag: image-classification
|
8 |
+
tags:
|
9 |
+
- backbone
|
10 |
+
- quantized
|
11 |
+
- android
|
12 |
+
|
13 |
+
---
|
14 |
+
|
15 |
+
![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/resnet50_quantized/web-assets/model_demo.png)
|
16 |
+
|
17 |
+
# ResNet50Quantized: Optimized for Mobile Deployment
|
18 |
+
## Imagenet classifier and general purpose backbone
|
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](https://github.com/pytorch/vision/blob/main/torchvision/models/resnet.py).
|
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).
|
26 |
+
|
27 |
+
|
28 |
+
### Model Details
|
29 |
+
|
30 |
+
- **Model Type:** Image classification
|
31 |
+
- **Model Stats:**
|
32 |
+
- Model checkpoint: Imagenet
|
33 |
+
- Input resolution: 224x224
|
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.814 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 | 0.997 ms | 0 - 7 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 "qai-hub-models[resnet50_quantized]"
|
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
|
60 |
+
Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.
|
61 |
+
|
62 |
+
With this API token, you can configure your client to run models on the cloud
|
63 |
+
hosted devices.
|
64 |
+
```bash
|
65 |
+
qai-hub configure --api_token API_TOKEN
|
66 |
+
```
|
67 |
+
Navigate to [docs](https://app.aihub.qualcomm.com/docs/) for more information.
|
68 |
+
|
69 |
+
|
70 |
+
|
71 |
+
## Demo off target
|
72 |
+
|
73 |
+
The package contains a simple end-to-end demo that downloads pre-trained
|
74 |
+
weights and runs this model on a sample input.
|
75 |
+
|
76 |
+
```bash
|
77 |
+
python -m qai_hub_models.models.resnet50_quantized.demo
|
78 |
+
```
|
79 |
+
|
80 |
+
The above demo runs a reference implementation of pre-processing, model
|
81 |
+
inference, and post processing.
|
82 |
+
|
83 |
+
**NOTE**: If you want running in a Jupyter Notebook or Google Colab like
|
84 |
+
environment, please add the following to your cell (instead of the above).
|
85 |
+
```
|
86 |
+
%run -m qai_hub_models.models.resnet50_quantized.demo
|
87 |
+
```
|
88 |
+
|
89 |
+
|
90 |
+
### Run model on a cloud-hosted device
|
91 |
+
|
92 |
+
In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
|
93 |
+
device. This script does the following:
|
94 |
+
* Performance check on-device on a cloud-hosted device
|
95 |
+
* Downloads compiled assets that can be deployed on-device for Android.
|
96 |
+
* Accuracy check between PyTorch and on-device outputs.
|
97 |
+
|
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: 0.99 ms
|
107 |
+
Estimated Peak Memory Range: 0.53-0.53 MB
|
108 |
+
Compute Units: NPU (78) | Total (78)
|
109 |
+
|
110 |
+
|
111 |
+
```
|
112 |
+
|
113 |
+
|
114 |
+
|
115 |
+
|
116 |
+
## Run demo on a cloud-hosted device
|
117 |
+
|
118 |
+
You can also run the demo on-device.
|
119 |
+
|
120 |
+
```bash
|
121 |
+
python -m qai_hub_models.models.resnet50_quantized.demo --on-device
|
122 |
+
```
|
123 |
+
|
124 |
+
**NOTE**: If you want running in a Jupyter Notebook or Google Colab like
|
125 |
+
environment, please add the following to your cell (instead of the above).
|
126 |
+
```
|
127 |
+
%run -m qai_hub_models.models.resnet50_quantized.demo -- --on-device
|
128 |
+
```
|
129 |
+
|
130 |
+
|
131 |
+
## Deploying compiled model to Android
|
132 |
+
|
133 |
+
|
134 |
+
The models can be deployed using multiple runtimes:
|
135 |
+
- TensorFlow Lite (`.tflite` export): [This
|
136 |
+
tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
|
137 |
+
guide to deploy the .tflite model in an Android application.
|
138 |
+
|
139 |
+
|
140 |
+
- QNN (`.so` export ): This [sample
|
141 |
+
app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
|
142 |
+
provides instructions on how to use the `.so` shared library in an Android application.
|
143 |
+
|
144 |
+
|
145 |
+
## View on Qualcomm® AI Hub
|
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 |
+
- The license for the original implementation of ResNet50Quantized can be found
|
151 |
+
[here](https://github.com/pytorch/vision/blob/main/LICENSE).
|
152 |
+
- 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)
|
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://qualcomm-ai-hub.slack.com/join/shared_invite/zt-2d5zsmas3-Sj0Q9TzslueCjS31eXG2UA#/shared-invite/email) to collaborate, post questions and learn more about on-device AI.
|
160 |
+
* For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
|
161 |
+
|
162 |
+
|