Spaces:
Paused
Paused
Update app_quant_latent.py
Browse files- app_quant_latent.py +4 -4
app_quant_latent.py
CHANGED
|
@@ -593,7 +593,7 @@ def generate_image(prompt, height, width, steps, seed, guidance_scale=0.0):
|
|
| 593 |
try:
|
| 594 |
latents = safe_get_latents(pipe, height, width, generator, device, LOGS)
|
| 595 |
|
| 596 |
-
# ---
|
| 597 |
try:
|
| 598 |
with torch.no_grad():
|
| 599 |
latent_img_tensor = pipe.vae.decode(latents).sample # [1, 3, H, W]
|
|
@@ -605,10 +605,10 @@ def generate_image(prompt, height, width, steps, seed, guidance_scale=0.0):
|
|
| 605 |
|
| 606 |
latent_gallery.append(latent_img)
|
| 607 |
|
| 608 |
-
# Yield
|
| 609 |
yield None, latent_gallery, LOGS
|
| 610 |
|
| 611 |
-
# --- Final image
|
| 612 |
try:
|
| 613 |
with torch.no_grad():
|
| 614 |
final_img_tensor = pipe.vae.decode(latents).sample
|
|
@@ -621,7 +621,7 @@ def generate_image(prompt, height, width, steps, seed, guidance_scale=0.0):
|
|
| 621 |
final_gallery.append(final_img)
|
| 622 |
LOGS.append("✅ Advanced latent pipeline succeeded.")
|
| 623 |
|
| 624 |
-
# Save latents to dict and upload to
|
| 625 |
latent_dict = {"latents": latents.cpu(), "prompt": prompt, "seed": seed}
|
| 626 |
try:
|
| 627 |
hf_url = upload_latents_to_hf(latent_dict, filename=f"latents_{seed}.pt")
|
|
|
|
| 593 |
try:
|
| 594 |
latents = safe_get_latents(pipe, height, width, generator, device, LOGS)
|
| 595 |
|
| 596 |
+
# --- Latent preview only ---
|
| 597 |
try:
|
| 598 |
with torch.no_grad():
|
| 599 |
latent_img_tensor = pipe.vae.decode(latents).sample # [1, 3, H, W]
|
|
|
|
| 605 |
|
| 606 |
latent_gallery.append(latent_img)
|
| 607 |
|
| 608 |
+
# Yield latent preview immediately
|
| 609 |
yield None, latent_gallery, LOGS
|
| 610 |
|
| 611 |
+
# --- Final image decoding ---
|
| 612 |
try:
|
| 613 |
with torch.no_grad():
|
| 614 |
final_img_tensor = pipe.vae.decode(latents).sample
|
|
|
|
| 621 |
final_gallery.append(final_img)
|
| 622 |
LOGS.append("✅ Advanced latent pipeline succeeded.")
|
| 623 |
|
| 624 |
+
# Save latents to dict and upload to Hugging Face
|
| 625 |
latent_dict = {"latents": latents.cpu(), "prompt": prompt, "seed": seed}
|
| 626 |
try:
|
| 627 |
hf_url = upload_latents_to_hf(latent_dict, filename=f"latents_{seed}.pt")
|