Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -39,18 +39,29 @@ pipe.to("cuda")
|
|
| 39 |
def pipeline_debug_info(pipe):
|
| 40 |
info = []
|
| 41 |
|
| 42 |
-
#
|
|
|
|
|
|
|
|
|
|
| 43 |
try:
|
|
|
|
|
|
|
| 44 |
info.append(f"Transformer attention backend: {pipe.transformer.config.attn_implementation}")
|
| 45 |
except:
|
| 46 |
-
info.append("
|
| 47 |
|
| 48 |
-
#
|
| 49 |
try:
|
| 50 |
-
|
| 51 |
-
info.append(f"
|
| 52 |
-
except
|
| 53 |
-
info.append(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
return "\n".join(info)
|
| 56 |
|
|
@@ -79,7 +90,7 @@ def generate_image(prompt, height, width, num_inference_steps, seed, randomize_s
|
|
| 79 |
num_images = min(max(1, int(num_images)), 3)
|
| 80 |
|
| 81 |
# Debug pipe info
|
| 82 |
-
log(pipeline_debug_info())
|
| 83 |
|
| 84 |
generator = torch.Generator("cuda").manual_seed(int(seed))
|
| 85 |
|
|
@@ -96,18 +107,20 @@ def generate_image(prompt, height, width, num_inference_steps, seed, randomize_s
|
|
| 96 |
output_type="pil",
|
| 97 |
)
|
| 98 |
|
| 99 |
-
#
|
| 100 |
try:
|
| 101 |
-
|
| 102 |
-
log(f"
|
| 103 |
-
|
| 104 |
-
|
|
|
|
| 105 |
|
| 106 |
log("Pipeline finished.")
|
| 107 |
log("Returning images...")
|
| 108 |
|
| 109 |
return result.images, seed, log_buffer.getvalue()
|
| 110 |
|
|
|
|
| 111 |
# ------------------------
|
| 112 |
# GRADIO UI
|
| 113 |
# ------------------------
|
|
|
|
| 39 |
def pipeline_debug_info(pipe):
|
| 40 |
info = []
|
| 41 |
|
| 42 |
+
# Show basic pipeline internals
|
| 43 |
+
info.append("=== PIPELINE DEBUG INFO ===")
|
| 44 |
+
|
| 45 |
+
# Transformer info (Z-Image uses DiT/Transformer backbone)
|
| 46 |
try:
|
| 47 |
+
info.append(f"Transformer type: {pipe.transformer.__class__.__name__}")
|
| 48 |
+
info.append(f"Transformer sample_size: {pipe.transformer.config.sample_size}")
|
| 49 |
info.append(f"Transformer attention backend: {pipe.transformer.config.attn_implementation}")
|
| 50 |
except:
|
| 51 |
+
info.append("Transformer diagnostics failed")
|
| 52 |
|
| 53 |
+
# VAE diagnostics
|
| 54 |
try:
|
| 55 |
+
info.append(f"VAE latent channels: {pipe.vae.config.latent_channels}")
|
| 56 |
+
info.append(f"VAE scaling factor: {pipe.vae.config.scaling_factor}")
|
| 57 |
+
except:
|
| 58 |
+
info.append("VAE diagnostics failed")
|
| 59 |
+
|
| 60 |
+
# Attn backend globally
|
| 61 |
+
try:
|
| 62 |
+
info.append(f"Pipeline attention backend: {pipe.config.attn_implementation}")
|
| 63 |
+
except:
|
| 64 |
+
pass
|
| 65 |
|
| 66 |
return "\n".join(info)
|
| 67 |
|
|
|
|
| 90 |
num_images = min(max(1, int(num_images)), 3)
|
| 91 |
|
| 92 |
# Debug pipe info
|
| 93 |
+
log(pipeline_debug_info(pipe))
|
| 94 |
|
| 95 |
generator = torch.Generator("cuda").manual_seed(int(seed))
|
| 96 |
|
|
|
|
| 107 |
output_type="pil",
|
| 108 |
)
|
| 109 |
|
| 110 |
+
# Correct latent diagnostics (Z-Image uses VAE + Transformer)
|
| 111 |
try:
|
| 112 |
+
log(f"VAE latent channels: {pipe.vae.config.latent_channels}")
|
| 113 |
+
log(f"VAE scaling factor: {pipe.vae.config.scaling_factor}")
|
| 114 |
+
log(f"Transformer latent size: {pipe.transformer.config.sample_size}")
|
| 115 |
+
except Exception as e:
|
| 116 |
+
log(f"Latent diagnostics error: {e}")
|
| 117 |
|
| 118 |
log("Pipeline finished.")
|
| 119 |
log("Returning images...")
|
| 120 |
|
| 121 |
return result.images, seed, log_buffer.getvalue()
|
| 122 |
|
| 123 |
+
|
| 124 |
# ------------------------
|
| 125 |
# GRADIO UI
|
| 126 |
# ------------------------
|