Update app.py
Browse files
app.py
CHANGED
|
@@ -221,28 +221,20 @@ label, .gr-box label {
|
|
| 221 |
border-bottom-style: solid;
|
| 222 |
}
|
| 223 |
"""
|
| 224 |
-
base_model_id = "Tongyi-MAI/Z-Image-Turbo"
|
| 225 |
-
|
| 226 |
# Load the pipeline once at startup
|
| 227 |
print("Loading Z-Image-Turbo pipeline...")
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
from huggingface_hub import hf_hub_download
|
| 231 |
-
|
| 232 |
-
model = ZImageTransformer2DModel.from_single_file(
|
| 233 |
-
hf_hub_download(
|
| 234 |
-
"xiaopeng/Z-IMAGE-Update", "zImageTurbo_40BF16AIO.safetensors"
|
| 235 |
-
),
|
| 236 |
torch_dtype=torch.bfloat16,
|
|
|
|
| 237 |
)
|
|
|
|
| 238 |
|
| 239 |
-
#
|
| 240 |
-
pipe =
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
)
|
| 245 |
-
pipe = pipe.to("cuda")
|
| 246 |
|
| 247 |
@spaces.GPU
|
| 248 |
def generate_image(
|
|
|
|
| 221 |
border-bottom-style: solid;
|
| 222 |
}
|
| 223 |
"""
|
|
|
|
|
|
|
| 224 |
# Load the pipeline once at startup
|
| 225 |
print("Loading Z-Image-Turbo pipeline...")
|
| 226 |
+
pipe = DiffusionPipeline.from_pretrained(
|
| 227 |
+
"Tongyi-MAI/Z-Image-Turbo",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
torch_dtype=torch.bfloat16,
|
| 229 |
+
low_cpu_mem_usage=False,
|
| 230 |
)
|
| 231 |
+
pipe.to("cuda")
|
| 232 |
|
| 233 |
+
# ======== AoTI compilation + FA3 ========
|
| 234 |
+
# pipe.transformer.layers._repeated_blocks = ["ZImageTransformerBlock"]
|
| 235 |
+
# spaces.aoti_blocks_load(pipe.transformer.layers, "zerogpu-aoti/Z-Image", variant="fa3")
|
| 236 |
+
|
| 237 |
+
print("Pipeline loaded!")
|
|
|
|
|
|
|
| 238 |
|
| 239 |
@spaces.GPU
|
| 240 |
def generate_image(
|