qaihm-bot commited on
Commit
24f23e5
·
verified ·
1 Parent(s): acd7237

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

Files changed (4) hide show
  1. .gitattributes +1 -0
  2. DEPLOYMENT_MODEL_LICENSE.pdf +3 -0
  3. LICENSE +2 -0
  4. README.md +229 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ DEPLOYMENT_MODEL_LICENSE.pdf filter=lfs diff=lfs merge=lfs -text
DEPLOYMENT_MODEL_LICENSE.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4409f93b0e82531303b3e10f52f1fdfb56467a25f05b7441c6bbd8bb8a64b42c
3
+ size 109629
LICENSE ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ The license of the original trained model can be found at https://github.com/lllyasviel/ControlNet/blob/main/LICENSE.
2
+ The license for the deployable model files (.tflite, .onnx, .dlc, .bin, etc.) can be found in DEPLOYMENT_MODEL_LICENSE.pdf.
README.md ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_canny/web-assets/model_demo.png)
12
+
13
+ # ControlNet-Canny: 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-Canny found [here](https://github.com/lllyasviel/ControlNet).
20
+
21
+
22
+ This repository provides scripts to run ControlNet-Canny on Qualcomm® devices.
23
+ More details on model performance across various devices, can be found
24
+ [here](https://aihub.qualcomm.com/models/controlnet_canny).
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
+ | text_encoder | w8a16 | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | QNN_CONTEXT_BINARY | 5.37 ms | 0 - 3 MB | NPU | Use Export Script |
42
+ | text_encoder | w8a16 | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | QNN_CONTEXT_BINARY | 5.903 ms | 0 - 10 MB | NPU | Use Export Script |
43
+ | text_encoder | w8a16 | SA8255 (Proxy) | Qualcomm® SA8255P (Proxy) | QNN_CONTEXT_BINARY | 5.395 ms | 0 - 2 MB | NPU | Use Export Script |
44
+ | text_encoder | w8a16 | SA8650 (Proxy) | Qualcomm® SA8650P (Proxy) | QNN_CONTEXT_BINARY | 5.412 ms | 0 - 2 MB | NPU | Use Export Script |
45
+ | text_encoder | w8a16 | SA8775P ADP | Qualcomm® SA8775P | QNN_CONTEXT_BINARY | 5.903 ms | 0 - 10 MB | NPU | Use Export Script |
46
+ | text_encoder | w8a16 | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | QNN_CONTEXT_BINARY | 5.432 ms | 0 - 3 MB | NPU | Use Export Script |
47
+ | text_encoder | w8a16 | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | PRECOMPILED_QNN_ONNX | 5.743 ms | 0 - 3 MB | NPU | Use Export Script |
48
+ | text_encoder | w8a16 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | QNN_CONTEXT_BINARY | 3.872 ms | 0 - 18 MB | NPU | Use Export Script |
49
+ | text_encoder | w8a16 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | PRECOMPILED_QNN_ONNX | 4.067 ms | 0 - 20 MB | NPU | Use Export Script |
50
+ | text_encoder | w8a16 | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | QNN_CONTEXT_BINARY | 3.481 ms | 0 - 14 MB | NPU | Use Export Script |
51
+ | text_encoder | w8a16 | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | PRECOMPILED_QNN_ONNX | 3.255 ms | 0 - 13 MB | NPU | Use Export Script |
52
+ | text_encoder | w8a16 | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN_CONTEXT_BINARY | 5.792 ms | 1 - 1 MB | NPU | Use Export Script |
53
+ | text_encoder | w8a16 | Snapdragon X Elite CRD | Snapdragon® X Elite | PRECOMPILED_QNN_ONNX | 5.958 ms | 158 - 158 MB | NPU | Use Export Script |
54
+ | unet | w8a16 | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | QNN_CONTEXT_BINARY | 110.879 ms | 13 - 15 MB | NPU | Use Export Script |
55
+ | unet | w8a16 | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | QNN_CONTEXT_BINARY | 107.956 ms | 6 - 13 MB | NPU | Use Export Script |
56
+ | unet | w8a16 | SA8255 (Proxy) | Qualcomm® SA8255P (Proxy) | QNN_CONTEXT_BINARY | 116.595 ms | 13 - 15 MB | NPU | Use Export Script |
57
+ | unet | w8a16 | SA8650 (Proxy) | Qualcomm® SA8650P (Proxy) | QNN_CONTEXT_BINARY | 115.724 ms | 13 - 16 MB | NPU | Use Export Script |
58
+ | unet | w8a16 | SA8775P ADP | Qualcomm® SA8775P | QNN_CONTEXT_BINARY | 107.956 ms | 6 - 13 MB | NPU | Use Export Script |
59
+ | unet | w8a16 | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | QNN_CONTEXT_BINARY | 117.156 ms | 13 - 16 MB | NPU | Use Export Script |
60
+ | unet | w8a16 | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | PRECOMPILED_QNN_ONNX | 116.818 ms | 0 - 883 MB | NPU | Use Export Script |
61
+ | unet | w8a16 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | QNN_CONTEXT_BINARY | 81.085 ms | 13 - 31 MB | NPU | Use Export Script |
62
+ | unet | w8a16 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | PRECOMPILED_QNN_ONNX | 84.025 ms | 13 - 32 MB | NPU | Use Export Script |
63
+ | unet | w8a16 | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | QNN_CONTEXT_BINARY | 70.612 ms | 13 - 27 MB | NPU | Use Export Script |
64
+ | unet | w8a16 | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | PRECOMPILED_QNN_ONNX | 70.807 ms | 13 - 28 MB | NPU | Use Export Script |
65
+ | unet | w8a16 | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN_CONTEXT_BINARY | 116.726 ms | 13 - 13 MB | NPU | Use Export Script |
66
+ | unet | w8a16 | Snapdragon X Elite CRD | Snapdragon® X Elite | PRECOMPILED_QNN_ONNX | 117.502 ms | 829 - 829 MB | NPU | Use Export Script |
67
+ | vae | w8a16 | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | QNN_CONTEXT_BINARY | 268.758 ms | 0 - 3 MB | NPU | Use Export Script |
68
+ | vae | w8a16 | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | QNN_CONTEXT_BINARY | 248.983 ms | 0 - 10 MB | NPU | Use Export Script |
69
+ | vae | w8a16 | SA8255 (Proxy) | Qualcomm® SA8255P (Proxy) | QNN_CONTEXT_BINARY | 272.989 ms | 0 - 2 MB | NPU | Use Export Script |
70
+ | vae | w8a16 | SA8650 (Proxy) | Qualcomm® SA8650P (Proxy) | QNN_CONTEXT_BINARY | 284.628 ms | 0 - 2 MB | NPU | Use Export Script |
71
+ | vae | w8a16 | SA8775P ADP | Qualcomm® SA8775P | QNN_CONTEXT_BINARY | 248.983 ms | 0 - 10 MB | NPU | Use Export Script |
72
+ | vae | w8a16 | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | QNN_CONTEXT_BINARY | 270.831 ms | 0 - 3 MB | NPU | Use Export Script |
73
+ | vae | w8a16 | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | PRECOMPILED_QNN_ONNX | 273.364 ms | 0 - 66 MB | NPU | Use Export Script |
74
+ | vae | w8a16 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | QNN_CONTEXT_BINARY | 205.993 ms | 0 - 18 MB | NPU | Use Export Script |
75
+ | vae | w8a16 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | PRECOMPILED_QNN_ONNX | 204.786 ms | 3 - 22 MB | NPU | Use Export Script |
76
+ | vae | w8a16 | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | QNN_CONTEXT_BINARY | 194.607 ms | 0 - 14 MB | NPU | Use Export Script |
77
+ | vae | w8a16 | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | PRECOMPILED_QNN_ONNX | 193.998 ms | 3 - 17 MB | NPU | Use Export Script |
78
+ | vae | w8a16 | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN_CONTEXT_BINARY | 266.935 ms | 0 - 0 MB | NPU | Use Export Script |
79
+ | vae | w8a16 | Snapdragon X Elite CRD | Snapdragon® X Elite | PRECOMPILED_QNN_ONNX | 266.448 ms | 63 - 63 MB | NPU | Use Export Script |
80
+ | controlnet | w8a16 | QCS8550 (Proxy) | Qualcomm® QCS8550 (Proxy) | QNN_CONTEXT_BINARY | 83.197 ms | 2 - 4 MB | NPU | Use Export Script |
81
+ | controlnet | w8a16 | QCS9075 (Proxy) | Qualcomm® QCS9075 (Proxy) | QNN_CONTEXT_BINARY | 81.755 ms | 2 - 11 MB | NPU | Use Export Script |
82
+ | controlnet | w8a16 | SA8255 (Proxy) | Qualcomm® SA8255P (Proxy) | QNN_CONTEXT_BINARY | 83.451 ms | 2 - 5 MB | NPU | Use Export Script |
83
+ | controlnet | w8a16 | SA8650 (Proxy) | Qualcomm® SA8650P (Proxy) | QNN_CONTEXT_BINARY | 83.565 ms | 2 - 4 MB | NPU | Use Export Script |
84
+ | controlnet | w8a16 | SA8775P ADP | Qualcomm® SA8775P | QNN_CONTEXT_BINARY | 81.755 ms | 2 - 11 MB | NPU | Use Export Script |
85
+ | controlnet | w8a16 | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | QNN_CONTEXT_BINARY | 83.39 ms | 2 - 5 MB | NPU | Use Export Script |
86
+ | controlnet | w8a16 | Samsung Galaxy S23 | Snapdragon® 8 Gen 2 Mobile | PRECOMPILED_QNN_ONNX | 86.158 ms | 0 - 384 MB | NPU | Use Export Script |
87
+ | controlnet | w8a16 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | QNN_CONTEXT_BINARY | 58.723 ms | 2 - 21 MB | NPU | Use Export Script |
88
+ | controlnet | w8a16 | Samsung Galaxy S24 | Snapdragon® 8 Gen 3 Mobile | PRECOMPILED_QNN_ONNX | 59.623 ms | 32 - 50 MB | NPU | Use Export Script |
89
+ | controlnet | w8a16 | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | QNN_CONTEXT_BINARY | 56.385 ms | 2 - 16 MB | NPU | Use Export Script |
90
+ | controlnet | w8a16 | Snapdragon 8 Elite QRD | Snapdragon® 8 Elite Mobile | PRECOMPILED_QNN_ONNX | 57.339 ms | 31 - 45 MB | NPU | Use Export Script |
91
+ | controlnet | w8a16 | Snapdragon X Elite CRD | Snapdragon® X Elite | QNN_CONTEXT_BINARY | 85.054 ms | 2 - 2 MB | NPU | Use Export Script |
92
+ | controlnet | w8a16 | Snapdragon X Elite CRD | Snapdragon® X Elite | PRECOMPILED_QNN_ONNX | 80.108 ms | 351 - 351 MB | NPU | Use Export Script |
93
+
94
+
95
+
96
+
97
+ ## Installation
98
+
99
+
100
+ Install the package via pip:
101
+ ```bash
102
+ pip install "qai-hub-models[controlnet-canny]"
103
+ ```
104
+
105
+
106
+ ## Configure Qualcomm® AI Hub to run this model on a cloud-hosted device
107
+
108
+ Sign-in to [Qualcomm® AI Hub](https://app.aihub.qualcomm.com/) with your
109
+ Qualcomm® ID. Once signed in navigate to `Account -> Settings -> API Token`.
110
+
111
+ With this API token, you can configure your client to run models on the cloud
112
+ hosted devices.
113
+ ```bash
114
+ qai-hub configure --api_token API_TOKEN
115
+ ```
116
+ Navigate to [docs](https://app.aihub.qualcomm.com/docs/) for more information.
117
+
118
+
119
+
120
+ ## Demo off target
121
+
122
+ The package contains a simple end-to-end demo that downloads pre-trained
123
+ weights and runs this model on a sample input.
124
+
125
+ ```bash
126
+ python -m qai_hub_models.models.controlnet_canny.demo
127
+ ```
128
+
129
+ The above demo runs a reference implementation of pre-processing, model
130
+ inference, and post processing.
131
+
132
+ **NOTE**: If you want running in a Jupyter Notebook or Google Colab like
133
+ environment, please add the following to your cell (instead of the above).
134
+ ```
135
+ %run -m qai_hub_models.models.controlnet_canny.demo
136
+ ```
137
+
138
+
139
+ ### Run model on a cloud-hosted device
140
+
141
+ In addition to the demo, you can also run the model on a cloud-hosted Qualcomm®
142
+ device. This script does the following:
143
+ * Performance check on-device on a cloud-hosted device
144
+ * Downloads compiled assets that can be deployed on-device for Android.
145
+ * Accuracy check between PyTorch and on-device outputs.
146
+
147
+ ```bash
148
+ python -m qai_hub_models.models.controlnet_canny.export
149
+ ```
150
+ ```
151
+ Profiling Results
152
+ ------------------------------------------------------------
153
+ text_encoder
154
+ Device : cs_8550 (ANDROID 12)
155
+ Runtime : QNN_CONTEXT_BINARY
156
+ Estimated inference time (ms) : 5.4
157
+ Estimated peak memory usage (MB): [0, 3]
158
+ Total # Ops : 438
159
+ Compute Unit(s) : npu (438 ops) gpu (0 ops) cpu (0 ops)
160
+
161
+ ------------------------------------------------------------
162
+ unet
163
+ Device : cs_8550 (ANDROID 12)
164
+ Runtime : QNN_CONTEXT_BINARY
165
+ Estimated inference time (ms) : 110.9
166
+ Estimated peak memory usage (MB): [13, 15]
167
+ Total # Ops : 4055
168
+ Compute Unit(s) : npu (4055 ops) gpu (0 ops) cpu (0 ops)
169
+
170
+ ------------------------------------------------------------
171
+ vae
172
+ Device : cs_8550 (ANDROID 12)
173
+ Runtime : QNN_CONTEXT_BINARY
174
+ Estimated inference time (ms) : 268.8
175
+ Estimated peak memory usage (MB): [0, 3]
176
+ Total # Ops : 175
177
+ Compute Unit(s) : npu (175 ops) gpu (0 ops) cpu (0 ops)
178
+
179
+ ------------------------------------------------------------
180
+ controlnet
181
+ Device : cs_8550 (ANDROID 12)
182
+ Runtime : QNN_CONTEXT_BINARY
183
+ Estimated inference time (ms) : 83.2
184
+ Estimated peak memory usage (MB): [2, 4]
185
+ Total # Ops : 664
186
+ Compute Unit(s) : npu (664 ops) gpu (0 ops) cpu (0 ops)
187
+ ```
188
+
189
+
190
+
191
+
192
+
193
+ ## Deploying compiled model to Android
194
+
195
+
196
+ The models can be deployed using multiple runtimes:
197
+ - TensorFlow Lite (`.tflite` export): [This
198
+ tutorial](https://www.tensorflow.org/lite/android/quickstart) provides a
199
+ guide to deploy the .tflite model in an Android application.
200
+
201
+
202
+ - QNN (`.so` export ): This [sample
203
+ app](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-50/sample_app.html)
204
+ provides instructions on how to use the `.so` shared library in an Android application.
205
+
206
+
207
+ ## View on Qualcomm® AI Hub
208
+ Get more details on ControlNet-Canny's performance across various devices [here](https://aihub.qualcomm.com/models/controlnet_canny).
209
+ Explore all available models on [Qualcomm® AI Hub](https://aihub.qualcomm.com/)
210
+
211
+
212
+ ## License
213
+ * The license for the original implementation of ControlNet-Canny can be found
214
+ [here](https://github.com/lllyasviel/ControlNet/blob/main/LICENSE).
215
+ * 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)
216
+
217
+
218
+
219
+ ## References
220
+ * [Adding Conditional Control to Text-to-Image Diffusion Models](https://arxiv.org/abs/2302.05543)
221
+ * [Source Model Implementation](https://github.com/lllyasviel/ControlNet)
222
+
223
+
224
+
225
+ ## Community
226
+ * Join [our AI Hub Slack community](https://aihub.qualcomm.com/community/slack) to collaborate, post questions and learn more about on-device AI.
227
+ * For questions or feedback please [reach out to us](mailto:ai-hub-support@qti.qualcomm.com).
228
+
229
+