Spaces:
Paused
Paused
Update app_quant_latent1.py
Browse files- app_quant_latent1.py +8 -8
app_quant_latent1.py
CHANGED
|
@@ -322,8 +322,8 @@ def generate_image(prompt, height, width, steps, seed, guidance_scale=0.0):
|
|
| 322 |
LOGS.append(msg)
|
| 323 |
print(msg)
|
| 324 |
|
| 325 |
-
|
| 326 |
-
generator = torch.Generator(device).manual_seed(int(seed))
|
| 327 |
|
| 328 |
log("π¨ START IMAGE GENERATION")
|
| 329 |
|
|
@@ -331,7 +331,7 @@ log("π¨ START IMAGE GENERATION")
|
|
| 331 |
# ==========================================================
|
| 332 |
# π§ͺ TRY ADVANCED LATENT GENERATOR (Your original generate())
|
| 333 |
# ==========================================================
|
| 334 |
-
latents, latent_err = safe_generate_with_latents(
|
| 335 |
transformer=transformer,
|
| 336 |
vae=vae,
|
| 337 |
text_encoder=text_encoder,
|
|
@@ -349,9 +349,9 @@ latents, latent_err = safe_generate_with_latents(
|
|
| 349 |
cfg_normalization=False,
|
| 350 |
cfg_truncation=1.0,
|
| 351 |
max_sequence_length=4096,
|
| 352 |
-
)
|
| 353 |
|
| 354 |
-
if latent_err is None:
|
| 355 |
log("β
Latent generator succeeded.")
|
| 356 |
try:
|
| 357 |
# Decode latents to image
|
|
@@ -372,14 +372,14 @@ if latent_err is None:
|
|
| 372 |
log(f"β οΈ Latent decode failed: {decode_error}")
|
| 373 |
log("π Falling back to standard pipeline...")
|
| 374 |
|
| 375 |
-
else:
|
| 376 |
log(f"β οΈ Latent generator failed: {latent_err}")
|
| 377 |
log("π Switching to standard pipeline...")
|
| 378 |
|
| 379 |
# ==========================================================
|
| 380 |
# π© STANDARD PIPELINE FALLBACK (Never fails)
|
| 381 |
# ==========================================================
|
| 382 |
-
try:
|
| 383 |
output = pipe(
|
| 384 |
prompt=prompt,
|
| 385 |
height=height,
|
|
@@ -392,7 +392,7 @@ try:
|
|
| 392 |
log("π’ Standard pipeline succeeded.")
|
| 393 |
return image, None, LOGS
|
| 394 |
|
| 395 |
-
except Exception as e:
|
| 396 |
log(f"β Standard pipeline failed: {e}")
|
| 397 |
return None, None, LOGS
|
| 398 |
|
|
|
|
| 322 |
LOGS.append(msg)
|
| 323 |
print(msg)
|
| 324 |
|
| 325 |
+
|
| 326 |
+
generator = torch.Generator(device).manual_seed(int(seed))
|
| 327 |
|
| 328 |
log("π¨ START IMAGE GENERATION")
|
| 329 |
|
|
|
|
| 331 |
# ==========================================================
|
| 332 |
# π§ͺ TRY ADVANCED LATENT GENERATOR (Your original generate())
|
| 333 |
# ==========================================================
|
| 334 |
+
latents, latent_err = safe_generate_with_latents(
|
| 335 |
transformer=transformer,
|
| 336 |
vae=vae,
|
| 337 |
text_encoder=text_encoder,
|
|
|
|
| 349 |
cfg_normalization=False,
|
| 350 |
cfg_truncation=1.0,
|
| 351 |
max_sequence_length=4096,
|
| 352 |
+
)
|
| 353 |
|
| 354 |
+
if latent_err is None:
|
| 355 |
log("β
Latent generator succeeded.")
|
| 356 |
try:
|
| 357 |
# Decode latents to image
|
|
|
|
| 372 |
log(f"β οΈ Latent decode failed: {decode_error}")
|
| 373 |
log("π Falling back to standard pipeline...")
|
| 374 |
|
| 375 |
+
else:
|
| 376 |
log(f"β οΈ Latent generator failed: {latent_err}")
|
| 377 |
log("π Switching to standard pipeline...")
|
| 378 |
|
| 379 |
# ==========================================================
|
| 380 |
# π© STANDARD PIPELINE FALLBACK (Never fails)
|
| 381 |
# ==========================================================
|
| 382 |
+
try:
|
| 383 |
output = pipe(
|
| 384 |
prompt=prompt,
|
| 385 |
height=height,
|
|
|
|
| 392 |
log("π’ Standard pipeline succeeded.")
|
| 393 |
return image, None, LOGS
|
| 394 |
|
| 395 |
+
except Exception as e:
|
| 396 |
log(f"β Standard pipeline failed: {e}")
|
| 397 |
return None, None, LOGS
|
| 398 |
|