Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
@@ -168,14 +168,29 @@ from qai_hub_models.models.controlnet_quantized import Model
|
|
168 |
|
169 |
# Load the model
|
170 |
model = Model.from_pretrained()
|
|
|
171 |
text_encoder_model = model.text_encoder
|
172 |
unet_model = model.unet
|
173 |
vae_decoder_model = model.vae_decoder
|
174 |
-
controlnet_model = model.controlnet
|
175 |
|
176 |
# Device
|
177 |
device = hub.Device("Samsung Galaxy S23")
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
# Trace model
|
180 |
text_encoder_input_shape = text_encoder_model.get_input_spec()
|
181 |
text_encoder_sample_inputs = text_encoder_model.sample_inputs()
|
@@ -221,21 +236,6 @@ vae_decoder_compile_job = hub.submit_compile_job(
|
|
221 |
|
222 |
# Get target model to run on-device
|
223 |
vae_decoder_target_model = vae_decoder_compile_job.get_target_model()
|
224 |
-
# Trace model
|
225 |
-
controlnet_input_shape = controlnet_model.get_input_spec()
|
226 |
-
controlnet_sample_inputs = controlnet_model.sample_inputs()
|
227 |
-
|
228 |
-
traced_controlnet_model = torch.jit.trace(controlnet_model, [torch.tensor(data[0]) for _, data in controlnet_sample_inputs.items()])
|
229 |
-
|
230 |
-
# Compile model on a specific device
|
231 |
-
controlnet_compile_job = hub.submit_compile_job(
|
232 |
-
model=traced_controlnet_model ,
|
233 |
-
device=device,
|
234 |
-
input_specs=controlnet_model.get_input_spec(),
|
235 |
-
)
|
236 |
-
|
237 |
-
# Get target model to run on-device
|
238 |
-
controlnet_target_model = controlnet_compile_job.get_target_model()
|
239 |
|
240 |
```
|
241 |
|
@@ -250,6 +250,10 @@ provided job URL to view a variety of on-device performance metrics.
|
|
250 |
|
251 |
# Device
|
252 |
device = hub.Device("Samsung Galaxy S23")
|
|
|
|
|
|
|
|
|
253 |
profile_job_textencoder_quantized = hub.submit_profile_job(
|
254 |
model=model_textencoder_quantized,
|
255 |
device=device,
|
@@ -262,10 +266,6 @@ profile_job_vaedecoder_quantized = hub.submit_profile_job(
|
|
262 |
model=model_vaedecoder_quantized,
|
263 |
device=device,
|
264 |
)
|
265 |
-
profile_job_controlnet_quantized = hub.submit_profile_job(
|
266 |
-
model=model_controlnet_quantized,
|
267 |
-
device=device,
|
268 |
-
)
|
269 |
|
270 |
```
|
271 |
|
@@ -275,6 +275,14 @@ To verify the accuracy of the model on-device, you can run on-device inference
|
|
275 |
on sample input data on the same cloud hosted device.
|
276 |
```python
|
277 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
input_data_textencoder_quantized = model.text_encoder.sample_inputs()
|
279 |
inference_job_textencoder_quantized = hub.submit_inference_job(
|
280 |
model=model_textencoder_quantized,
|
@@ -299,14 +307,6 @@ inference_job_vaedecoder_quantized = hub.submit_inference_job(
|
|
299 |
)
|
300 |
on_device_output_vaedecoder_quantized = inference_job_vaedecoder_quantized.download_output_data()
|
301 |
|
302 |
-
input_data_controlnet_quantized = model.controlnet.sample_inputs()
|
303 |
-
inference_job_controlnet_quantized = hub.submit_inference_job(
|
304 |
-
model=model_controlnet_quantized,
|
305 |
-
device=device,
|
306 |
-
inputs=input_data_controlnet_quantized,
|
307 |
-
)
|
308 |
-
on_device_output_controlnet_quantized = inference_job_controlnet_quantized.download_output_data()
|
309 |
-
|
310 |
```
|
311 |
With the output of the model, you can compute like PSNR, relative errors or
|
312 |
spot check the output with expected output.
|
|
|
168 |
|
169 |
# Load the model
|
170 |
model = Model.from_pretrained()
|
171 |
+
controlnet_model = model.controlnet
|
172 |
text_encoder_model = model.text_encoder
|
173 |
unet_model = model.unet
|
174 |
vae_decoder_model = model.vae_decoder
|
|
|
175 |
|
176 |
# Device
|
177 |
device = hub.Device("Samsung Galaxy S23")
|
178 |
|
179 |
+
# Trace model
|
180 |
+
controlnet_input_shape = controlnet_model.get_input_spec()
|
181 |
+
controlnet_sample_inputs = controlnet_model.sample_inputs()
|
182 |
+
|
183 |
+
traced_controlnet_model = torch.jit.trace(controlnet_model, [torch.tensor(data[0]) for _, data in controlnet_sample_inputs.items()])
|
184 |
+
|
185 |
+
# Compile model on a specific device
|
186 |
+
controlnet_compile_job = hub.submit_compile_job(
|
187 |
+
model=traced_controlnet_model ,
|
188 |
+
device=device,
|
189 |
+
input_specs=controlnet_model.get_input_spec(),
|
190 |
+
)
|
191 |
+
|
192 |
+
# Get target model to run on-device
|
193 |
+
controlnet_target_model = controlnet_compile_job.get_target_model()
|
194 |
# Trace model
|
195 |
text_encoder_input_shape = text_encoder_model.get_input_spec()
|
196 |
text_encoder_sample_inputs = text_encoder_model.sample_inputs()
|
|
|
236 |
|
237 |
# Get target model to run on-device
|
238 |
vae_decoder_target_model = vae_decoder_compile_job.get_target_model()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
|
240 |
```
|
241 |
|
|
|
250 |
|
251 |
# Device
|
252 |
device = hub.Device("Samsung Galaxy S23")
|
253 |
+
profile_job_controlnet_quantized = hub.submit_profile_job(
|
254 |
+
model=model_controlnet_quantized,
|
255 |
+
device=device,
|
256 |
+
)
|
257 |
profile_job_textencoder_quantized = hub.submit_profile_job(
|
258 |
model=model_textencoder_quantized,
|
259 |
device=device,
|
|
|
266 |
model=model_vaedecoder_quantized,
|
267 |
device=device,
|
268 |
)
|
|
|
|
|
|
|
|
|
269 |
|
270 |
```
|
271 |
|
|
|
275 |
on sample input data on the same cloud hosted device.
|
276 |
```python
|
277 |
|
278 |
+
input_data_controlnet_quantized = model.controlnet.sample_inputs()
|
279 |
+
inference_job_controlnet_quantized = hub.submit_inference_job(
|
280 |
+
model=model_controlnet_quantized,
|
281 |
+
device=device,
|
282 |
+
inputs=input_data_controlnet_quantized,
|
283 |
+
)
|
284 |
+
on_device_output_controlnet_quantized = inference_job_controlnet_quantized.download_output_data()
|
285 |
+
|
286 |
input_data_textencoder_quantized = model.text_encoder.sample_inputs()
|
287 |
inference_job_textencoder_quantized = hub.submit_inference_job(
|
288 |
model=model_textencoder_quantized,
|
|
|
307 |
)
|
308 |
on_device_output_vaedecoder_quantized = inference_job_vaedecoder_quantized.download_output_data()
|
309 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
```
|
311 |
With the output of the model, you can compute like PSNR, relative errors or
|
312 |
spot check the output with expected output.
|