Spaces:
Running
on
Zero
Running
on
Zero
fix bug
Browse files- __pycache__/app.cpython-37.pyc +0 -0
- app.py +11 -8
__pycache__/app.cpython-37.pyc
CHANGED
|
Binary files a/__pycache__/app.cpython-37.pyc and b/__pycache__/app.cpython-37.pyc differ
|
|
|
app.py
CHANGED
|
@@ -227,6 +227,7 @@ def generate_image(
|
|
| 227 |
neg_prompt = negative_prompt
|
| 228 |
|
| 229 |
images = []
|
|
|
|
| 230 |
for s in seeds:
|
| 231 |
generator = torch.Generator("cuda").manual_seed(int(s))
|
| 232 |
image = pipe(
|
|
@@ -239,21 +240,23 @@ def generate_image(
|
|
| 239 |
generator=generator,
|
| 240 |
).images[0]
|
| 241 |
images.append(image)
|
|
|
|
|
|
|
|
|
|
| 242 |
|
| 243 |
-
return images, ", ".join(str(s) for s in seeds),
|
| 244 |
|
| 245 |
|
| 246 |
-
def package_zip(
|
| 247 |
"""Pack the current image list into a ZIP file for download."""
|
| 248 |
-
if not
|
| 249 |
raise gr.Error("Please generate images first.")
|
| 250 |
|
| 251 |
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".zip")
|
| 252 |
with zipfile.ZipFile(tmp, "w", zipfile.ZIP_DEFLATED) as zf:
|
| 253 |
-
for idx,
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
zf.writestr(f"image_{idx:02d}.png", buf.getvalue())
|
| 257 |
|
| 258 |
tmp.flush()
|
| 259 |
return tmp.name
|
|
@@ -374,7 +377,7 @@ with gr.Blocks(title="Z-Image-Turbo Demo", css=CUSTOM_CSS, analytics_enabled=Fal
|
|
| 374 |
gr.Markdown(
|
| 375 |
"""
|
| 376 |
<div class="footer-note">
|
| 377 |
-
Model: Tongyi-MAI/Z-Image-Turbo (Apache 2.0). Demo by
|
| 378 |
</div>
|
| 379 |
"""
|
| 380 |
)
|
|
|
|
| 227 |
neg_prompt = negative_prompt
|
| 228 |
|
| 229 |
images = []
|
| 230 |
+
image_paths = []
|
| 231 |
for s in seeds:
|
| 232 |
generator = torch.Generator("cuda").manual_seed(int(s))
|
| 233 |
image = pipe(
|
|
|
|
| 240 |
generator=generator,
|
| 241 |
).images[0]
|
| 242 |
images.append(image)
|
| 243 |
+
tmp_img = tempfile.NamedTemporaryFile(delete=False, suffix=".png")
|
| 244 |
+
image.save(tmp_img.name, format="PNG")
|
| 245 |
+
image_paths.append(tmp_img.name)
|
| 246 |
|
| 247 |
+
return images, ", ".join(str(s) for s in seeds), image_paths
|
| 248 |
|
| 249 |
|
| 250 |
+
def package_zip(image_paths):
|
| 251 |
"""Pack the current image list into a ZIP file for download."""
|
| 252 |
+
if not image_paths:
|
| 253 |
raise gr.Error("Please generate images first.")
|
| 254 |
|
| 255 |
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".zip")
|
| 256 |
with zipfile.ZipFile(tmp, "w", zipfile.ZIP_DEFLATED) as zf:
|
| 257 |
+
for idx, path in enumerate(image_paths, start=1):
|
| 258 |
+
# Store as image_01.png, image_02.png, ...
|
| 259 |
+
zf.write(path, arcname=f"image_{idx:02d}.png")
|
|
|
|
| 260 |
|
| 261 |
tmp.flush()
|
| 262 |
return tmp.name
|
|
|
|
| 377 |
gr.Markdown(
|
| 378 |
"""
|
| 379 |
<div class="footer-note">
|
| 380 |
+
Model: Tongyi-MAI/Z-Image-Turbo (Apache 2.0). Demo by https://z-image-turbo.tech 路
|
| 381 |
</div>
|
| 382 |
"""
|
| 383 |
)
|