Spaces:
Paused
Paused
Update app_quant_latent1.py
Browse files- app_quant_latent1.py +40 -40
app_quant_latent1.py
CHANGED
|
@@ -251,49 +251,49 @@ from PIL import Image
|
|
| 251 |
import torch
|
| 252 |
|
| 253 |
def safe_generate_with_latents(
|
| 254 |
-
transformer,
|
| 255 |
-
vae,
|
| 256 |
-
text_encoder,
|
| 257 |
-
tokenizer,
|
| 258 |
-
scheduler,
|
| 259 |
-
pipe,
|
| 260 |
-
prompt,
|
| 261 |
-
height,
|
| 262 |
-
width,
|
| 263 |
-
steps,
|
| 264 |
-
guidance_scale,
|
| 265 |
-
negative_prompt,
|
| 266 |
-
num_images_per_prompt,
|
| 267 |
-
generator,
|
| 268 |
-
cfg_normalization,
|
| 269 |
-
cfg_truncation,
|
| 270 |
-
max_sequence_length,
|
| 271 |
-
):
|
| 272 |
|
| 273 |
try:
|
| 274 |
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
|
| 298 |
except Exception as e:
|
| 299 |
return None, e
|
|
|
|
| 251 |
import torch
|
| 252 |
|
| 253 |
def safe_generate_with_latents(
|
| 254 |
+
transformer,
|
| 255 |
+
vae,
|
| 256 |
+
text_encoder,
|
| 257 |
+
tokenizer,
|
| 258 |
+
scheduler,
|
| 259 |
+
pipe,
|
| 260 |
+
prompt,
|
| 261 |
+
height,
|
| 262 |
+
width,
|
| 263 |
+
steps,
|
| 264 |
+
guidance_scale,
|
| 265 |
+
negative_prompt,
|
| 266 |
+
num_images_per_prompt,
|
| 267 |
+
generator,
|
| 268 |
+
cfg_normalization,
|
| 269 |
+
cfg_truncation,
|
| 270 |
+
max_sequence_length,
|
| 271 |
+
):
|
| 272 |
|
| 273 |
try:
|
| 274 |
|
| 275 |
+
latents_or_images = generate(
|
| 276 |
+
transformer=transformer,
|
| 277 |
+
vae=vae,
|
| 278 |
+
text_encoder=text_encoder,
|
| 279 |
+
tokenizer=tokenizer,
|
| 280 |
+
scheduler=scheduler,
|
| 281 |
+
prompt=prompt,
|
| 282 |
+
height=height,
|
| 283 |
+
width=width,
|
| 284 |
+
num_inference_steps=steps,
|
| 285 |
+
guidance_scale=guidance_scale,
|
| 286 |
+
negative_prompt=negative_prompt,
|
| 287 |
+
num_images_per_prompt=num_images_per_prompt,
|
| 288 |
+
generator=generator,
|
| 289 |
+
cfg_normalization=cfg_normalization,
|
| 290 |
+
cfg_truncation=cfg_truncation,
|
| 291 |
+
max_sequence_length=max_sequence_length,
|
| 292 |
+
output_type="latent", # IMPORTANT
|
| 293 |
+
)
|
| 294 |
+
|
| 295 |
+
|
| 296 |
+
return latents_or_images, None
|
| 297 |
|
| 298 |
except Exception as e:
|
| 299 |
return None, e
|