qaihm-bot commited on
Commit
0ff89ab
·
verified ·
1 Parent(s): e9c0792

Deprecation notice.

Files changed (1) hide show
  1. README.md +4 -252
README.md CHANGED
@@ -1,258 +1,10 @@
 
1
  ---
2
  library_name: pytorch
3
  license: other
4
  tags:
5
- - generative_ai
6
- - android
7
- pipeline_tag: unconditional-image-generation
8
 
9
  ---
10
-
11
- ![](https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/controlnet/web-assets/model_demo.png)
12
-
13
- # ControlNet: Optimized for Mobile Deployment
14
- ## Generating visual arts from text prompt and input guiding image
15
-
16
-
17
- On-device, high-resolution image synthesis from text and image prompts. ControlNet guides Stable-diffusion with provided input image to generate accurate images from given input prompt.
18
-
19
- This model is an implementation of ControlNet found [here](https://github.com/lllyasviel/ControlNet).
20
-
21
-
22
- This repository provides scripts to run ControlNet on Qualcomm® devices.
23
- More details on model performance across various devices, can be found
24
- [here](https://aihub.qualcomm.com/models/controlnet).
25
-
26
-
27
- ### Model Details
28
-
29
- - **Model Type:** Model_use_case.image_generation
30
- - **Model Stats:**
31
- - Input: Text prompt and input image as a reference
32
- - Conditioning Input: Canny-Edge
33
- - Text Encoder Number of parameters: 340M
34
- - UNet Number of parameters: 865M
35
- - VAE Decoder Number of parameters: 83M
36
- - ControlNet Number of parameters: 361M
37
- - Model size: 1.4GB
38
-
39
- | Model | Precision | Device | Chipset | Target Runtime | Inference Time (ms) | Peak Memory Range (MB) | Primary Compute Unit | Target Model
40
- |---|---|---|---|---|---|---|---|---|
41
- | TextEncoder_Quantized | w8a16 | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | QNN_DLC | 10.874 ms | 0 - 3 MB | NPU | [ControlNet.dlc](https://huggingface.co/qualcomm/ControlNet/blob/main/ControlNet_w8a16.dlc) |
42
- | TextEncoder_Quantized | w8a16 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | QNN_DLC | 7.918 ms | 0 - 18 MB | NPU | [ControlNet.dlc](https://huggingface.co/qualcomm/ControlNet/blob/main/ControlNet_w8a16.dlc) |
43
- | TextEncoder_Quantized | w8a16 | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | QNN_DLC | 10.875 ms | 0 - 3 MB | NPU | [ControlNet.dlc](https://huggingface.co/qualcomm/ControlNet/blob/main/ControlNet_w8a16.dlc) |
44
- | UNet_Quantized | w8a16 | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | QNN_DLC | 258.151 ms | 13 - 15 MB | NPU | [ControlNet.dlc](https://huggingface.co/qualcomm/ControlNet/blob/main/ControlNet_w8a16.dlc) |
45
- | UNet_Quantized | w8a16 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | QNN_DLC | 197.629 ms | 13 - 31 MB | NPU | [ControlNet.dlc](https://huggingface.co/qualcomm/ControlNet/blob/main/ControlNet_w8a16.dlc) |
46
- | UNet_Quantized | w8a16 | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | QNN_DLC | 256.936 ms | 13 - 16 MB | NPU | [ControlNet.dlc](https://huggingface.co/qualcomm/ControlNet/blob/main/ControlNet_w8a16.dlc) |
47
- | VAEDecoder_Quantized | w8a16 | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | QNN_DLC | 397.625 ms | 0 - 2 MB | NPU | [ControlNet.dlc](https://huggingface.co/qualcomm/ControlNet/blob/main/ControlNet_w8a16.dlc) |
48
- | VAEDecoder_Quantized | w8a16 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | QNN_DLC | 300.627 ms | 0 - 21 MB | NPU | [ControlNet.dlc](https://huggingface.co/qualcomm/ControlNet/blob/main/ControlNet_w8a16.dlc) |
49
- | VAEDecoder_Quantized | w8a16 | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | QNN_DLC | 395.006 ms | 0 - 3 MB | NPU | [ControlNet.dlc](https://huggingface.co/qualcomm/ControlNet/blob/main/ControlNet_w8a16.dlc) |
50
- | ControlNet_Quantized | w8a16 | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | QNN_DLC | 104.668 ms | 2 - 9 MB | NPU | [ControlNet.dlc](https://huggingface.co/qualcomm/ControlNet/blob/main/ControlNet_w8a16.dlc) |
51
- | ControlNet_Quantized | w8a16 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | QNN_DLC | 77.289 ms | 2 - 23 MB | NPU | [ControlNet.dlc](https://huggingface.co/qualcomm/ControlNet/blob/main/ControlNet_w8a16.dlc) |
52
- | ControlNet_Quantized | w8a16 | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | QNN_DLC | 103.817 ms | 2 - 5 MB | NPU | [ControlNet.dlc](https://huggingface.co/qualcomm/ControlNet/blob/main/ControlNet_w8a16.dlc) |
53
-
54
-
55
-
56
-
57
- ## Installation
58
-
59
-
60
- Install the package via pip:
61
- ```bash
62
- pip install "qai-hub-models[controlnet]"
63
- ```
64
-
65
-
66
- ## Configure Qualcomm® AI Hub to run this model on a cloud-hosted device
67
-
68
- Sign-in to [Qualcomm® AI Hub](https://app.aihub.qualcomm.com/) with your
69
- Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.
70
-
71
- With this API token, you can configure your client to run models on the cloud
72
- hosted devices.
73
- ```bash
74
- qai-hub configure --api_token API_TOKEN
75
- ```
76
- Navigate to [docs](https://app.aihub.qualcomm.com/docs/) for more information.
77
-
78
-
79
-
80
- ## Demo on-device
81
-
82
- The package contains a simple end-to-end demo that downloads pre-trained
83
- weights and runs this model on a sample input.
84
-
85
- ```bash
86
- python -m qai_hub_models.models.controlnet.demo
87
- ```
88
-
89
- The above demo runs a reference implementation of pre-processing, model
90
- inference, and post processing.
91
-
92
- **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
93
- environment, please add the following to your cell (instead of the above).
94
- ```
95
- %run -m qai_hub_models.models.controlnet.demo
96
- ```
97
-
98
-
99
- ### Run model on a cloud-hosted device
100
-
101
- In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
102
- device. This script does the following:
103
- * Performance check on-device on a cloud-hosted device
104
- * Downloads compiled assets that can be deployed on-device for Android.
105
- * Accuracy check between PyTorch and on-device outputs.
106
-
107
- ```bash
108
- python -m qai_hub_models.models.controlnet.export
109
- ```
110
- ```
111
- Profiling Results
112
- ------------------------------------------------------------
113
- TextEncoder_Quantized
114
- Device : cs_8_gen_2 (ANDROID 13)
115
- Runtime : QNN_DLC
116
- Estimated inference time (ms) : 10.9
117
- Estimated peak memory usage (MB): [0, 3]
118
- Total # Ops : 569
119
- Compute Unit(s) : npu (569 ops) gpu (0 ops) cpu (0 ops)
120
-
121
- ------------------------------------------------------------
122
- UNet_Quantized
123
- Device : cs_8_gen_2 (ANDROID 13)
124
- Runtime : QNN_DLC
125
- Estimated inference time (ms) : 258.2
126
- Estimated peak memory usage (MB): [13, 15]
127
- Total # Ops : 5433
128
- Compute Unit(s) : npu (5433 ops) gpu (0 ops) cpu (0 ops)
129
-
130
- ------------------------------------------------------------
131
- VAEDecoder_Quantized
132
- Device : cs_8_gen_2 (ANDROID 13)
133
- Runtime : QNN_DLC
134
- Estimated inference time (ms) : 397.6
135
- Estimated peak memory usage (MB): [0, 2]
136
- Total # Ops : 408
137
- Compute Unit(s) : npu (408 ops) gpu (0 ops) cpu (0 ops)
138
-
139
- ------------------------------------------------------------
140
- ControlNet_Quantized
141
- Device : cs_8_gen_2 (ANDROID 13)
142
- Runtime : QNN_DLC
143
- Estimated inference time (ms) : 104.7
144
- Estimated peak memory usage (MB): [2, 9]
145
- Total # Ops : 2405
146
- Compute Unit(s) : npu (2405 ops) gpu (0 ops) cpu (0 ops)
147
- ```
148
-
149
-
150
- ## How does this work?
151
-
152
- This [export script](https://aihub.qualcomm.com/models/controlnet/qai_hub_models/models/ControlNet/export.py)
153
- leverages [Qualcomm® AI Hub](https://aihub.qualcomm.com/) to optimize, validate, and deploy this model
154
- on-device. Lets go through each step below in detail:
155
-
156
- Step 1: **Upload compiled model**
157
-
158
- Upload compiled models from `qai_hub_models.models.controlnet` on hub.
159
- ```python
160
- import torch
161
-
162
- import qai_hub as hub
163
- from qai_hub_models.models.controlnet import Model
164
-
165
- # Load the model
166
- model = Model.from_precompiled()
167
-
168
- ```
169
-
170
-
171
- Step 2: **Performance profiling on cloud-hosted device**
172
-
173
- After uploading compiled models from step 1. Models can be profiled model on-device using the
174
- `target_model`. Note that this scripts runs the model on a device automatically
175
- provisioned in the cloud. Once the job is submitted, you can navigate to a
176
- provided job URL to view a variety of on-device performance metrics.
177
- ```python
178
-
179
- # Device
180
- device = hub.Device("Samsung Galaxy S23")
181
-
182
- ```
183
-
184
- Step 3: **Verify on-device accuracy**
185
-
186
- To verify the accuracy of the model on-device, you can run on-device inference
187
- on sample input data on the same cloud hosted device.
188
- ```python
189
-
190
- ```
191
- With the output of the model, you can compute like PSNR, relative errors or
192
- spot check the output with expected output.
193
-
194
- **Note**: This on-device profiling and inference requires access to Qualcomm®
195
- AI Hub. [Sign up for access](https://myaccount.qualcomm.com/signup).
196
-
197
-
198
-
199
-
200
- ## Deploying compiled model to Android
201
-
202
-
203
- The models can be deployed using multiple runtimes:
204
- - TensorFlow Lite (`.tflite` export): [This
205
- tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
206
- guide to deploy the .tflite model in an Android application.
207
-
208
-
209
- - QNN ( `.so` / `.bin` export ): This [sample
210
- app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
211
- provides instructions on how to use the `.so` shared library or `.bin` context binary in an Android application.
212
-
213
-
214
- ## View on Qualcomm® AI Hub
215
- Get more details on ControlNet's performance across various devices [here](https://aihub.qualcomm.com/models/controlnet).
216
- Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
217
-
218
-
219
- ## License
220
- * The license for the original implementation of ControlNet can be found
221
- [here](https://github.com/lllyasviel/ControlNet/blob/main/LICENSE).
222
- * 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)
223
-
224
-
225
-
226
- ## References
227
- * [Adding Conditional Control to Text-to-Image Diffusion Models](https://arxiv.org/abs/2302.05543)
228
- * [Source Model Implementation](https://github.com/lllyasviel/ControlNet)
229
-
230
-
231
-
232
- ## Community
233
- * Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
234
- * For questions or feedback please [reach out to us](mailto:[email protected]).
235
-
236
-
237
- ## Usage and Limitations
238
-
239
- This model may not be used for or in connection with any of the following applications:
240
-
241
- - Accessing essential private and public services and benefits;
242
- - Administration of justice and democratic processes;
243
- - Assessing or recognizing the emotional state of a person;
244
- - Biometric and biometrics-based systems, including categorization of persons based on sensitive characteristics;
245
- - Education and vocational training;
246
- - Employment and workers management;
247
- - Exploitation of the vulnerabilities of persons resulting in harmful behavior;
248
- - General purpose social scoring;
249
- - Law enforcement;
250
- - Management and operation of critical infrastructure;
251
- - Migration, asylum and border control management;
252
- - Predictive policing;
253
- - Real-time remote biometric identification in public spaces;
254
- - Recommender systems of social media platforms;
255
- - Scraping of facial images (from the internet or otherwise); and/or
256
- - Subliminal manipulation
257
-
258
-
 
1
+
2
  ---
3
  library_name: pytorch
4
  license: other
5
  tags:
6
+ - deprecated
7
+ pipeline_tag: other
 
8
 
9
  ---
10
+ This model is deprecated. Please refer to https://aihub.qualcomm.com for the latest models and updates.