Spaces:
Running on Zero
Running on Zero
Alexander Bagus commited on
Commit ·
310a5dc
1
Parent(s): af74fd1
update max resolutions and test aoti
Browse files- app.py +5 -13
- static/footer.md +7 -3
app.py
CHANGED
|
@@ -8,14 +8,6 @@ from diffusers import ZImagePipeline
|
|
| 8 |
# ==================== Configuration ====================
|
| 9 |
MODEL_PATH = "Tongyi-MAI/Z-Image"
|
| 10 |
|
| 11 |
-
EXAMPLE_PROMPTS = [
|
| 12 |
-
["一位男士和他的贵宾犬穿着配套的服装参加狗狗秀,室内灯光,背景中有观众。"],
|
| 13 |
-
["极具氛围感的暗调人像,一位优雅的中国美女在黑暗的房间里。一束强光通过遮光板,在她的脸上投射出一个清晰的闪电形状的光影,正好照亮一只眼睛。高对比度,明暗交界清晰,神秘感,莱卡相机色调。"],
|
| 14 |
-
["Young Chinese woman in red Hanfu, intricate embroidery. Impeccable makeup, red floral forehead pattern. Elaborate high bun, golden phoenix headdress, red flowers, beads. Holds round folding fan with lady, trees, bird. Soft-lit outdoor night background, silhouetted tiered pagoda, blurred colorful distant lights."],
|
| 15 |
-
["A serene mountain landscape at sunset with golden light reflecting off a calm lake, surrounded by pine trees"],
|
| 16 |
-
["A futuristic cityscape with flying cars and neon holographic advertisements, cyberpunk style"],
|
| 17 |
-
]
|
| 18 |
-
|
| 19 |
# ==================== Model Loading (Global Context) ====================
|
| 20 |
print(f"Loading Z-Image pipeline from {MODEL_PATH}...")
|
| 21 |
pipe = ZImagePipeline.from_pretrained(
|
|
@@ -26,8 +18,8 @@ pipe = ZImagePipeline.from_pretrained(
|
|
| 26 |
pipe.to("cuda")
|
| 27 |
print("Pipeline loaded successfully!")
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
|
| 32 |
|
| 33 |
# ==================== Generation Function ====================
|
|
@@ -129,7 +121,7 @@ with gr.Blocks(title="Z-Image Demo") as demo:
|
|
| 129 |
width = gr.Slider(
|
| 130 |
label="Width",
|
| 131 |
minimum=512,
|
| 132 |
-
maximum=
|
| 133 |
step=32,
|
| 134 |
value=1024,
|
| 135 |
)
|
|
@@ -137,7 +129,7 @@ with gr.Blocks(title="Z-Image Demo") as demo:
|
|
| 137 |
height = gr.Slider(
|
| 138 |
label="Height",
|
| 139 |
minimum=512,
|
| 140 |
-
maximum=
|
| 141 |
step=32,
|
| 142 |
value=1024,
|
| 143 |
)
|
|
@@ -149,7 +141,7 @@ with gr.Blocks(title="Z-Image Demo") as demo:
|
|
| 149 |
with gr.Row():
|
| 150 |
num_inference_steps = gr.Slider(
|
| 151 |
label="Inference Steps",
|
| 152 |
-
minimum=
|
| 153 |
maximum=50,
|
| 154 |
value=28,
|
| 155 |
step=1
|
|
|
|
| 8 |
# ==================== Configuration ====================
|
| 9 |
MODEL_PATH = "Tongyi-MAI/Z-Image"
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
# ==================== Model Loading (Global Context) ====================
|
| 12 |
print(f"Loading Z-Image pipeline from {MODEL_PATH}...")
|
| 13 |
pipe = ZImagePipeline.from_pretrained(
|
|
|
|
| 18 |
pipe.to("cuda")
|
| 19 |
print("Pipeline loaded successfully!")
|
| 20 |
|
| 21 |
+
pipe.transformer.layers._repeated_blocks = ["ZImageTransformerBlock"]
|
| 22 |
+
spaces.aoti_blocks_load(pipe.transformer.layers, "zerogpu-aoti/Z-Image", variant="fa3")
|
| 23 |
|
| 24 |
|
| 25 |
# ==================== Generation Function ====================
|
|
|
|
| 121 |
width = gr.Slider(
|
| 122 |
label="Width",
|
| 123 |
minimum=512,
|
| 124 |
+
maximum=2048,
|
| 125 |
step=32,
|
| 126 |
value=1024,
|
| 127 |
)
|
|
|
|
| 129 |
height = gr.Slider(
|
| 130 |
label="Height",
|
| 131 |
minimum=512,
|
| 132 |
+
maximum=2048,
|
| 133 |
step=32,
|
| 134 |
value=1024,
|
| 135 |
)
|
|
|
|
| 141 |
with gr.Row():
|
| 142 |
num_inference_steps = gr.Slider(
|
| 143 |
label="Inference Steps",
|
| 144 |
+
minimum=12,
|
| 145 |
maximum=50,
|
| 146 |
value=28,
|
| 147 |
step=1
|
static/footer.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
|
| 5 |
After a moment, your image will be generated.
|
| 6 |
|
| 7 |
-
**Known
|
| 8 |
|
| 9 |
**If you like the result, please hit the like button! 😄**
|
| 10 |
|
|
@@ -16,8 +16,12 @@ You can get the ComfyUI version here: <https://huggingface.co/Comfy-Org/z_image>
|
|
| 16 |
- Generates images with text.
|
| 17 |
- Good aesthetic results.
|
| 18 |
|
| 19 |
-
##
|
| 20 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
## References
|
| 23 |
- **Tongyi-MAI**: <https://huggingface.co/Tongyi-MAI>
|
|
|
|
| 4 |
|
| 5 |
After a moment, your image will be generated.
|
| 6 |
|
| 7 |
+
**Known bugs:** Sometimes the new image won't load properly and will show the previous result. If this happens, click the image in the gallery to load the newly generated images.
|
| 8 |
|
| 9 |
**If you like the result, please hit the like button! 😄**
|
| 10 |
|
|
|
|
| 16 |
- Generates images with text.
|
| 17 |
- Good aesthetic results.
|
| 18 |
|
| 19 |
+
### Recommended Settings for Z-Image Base
|
| 20 |
+
- **Resolution:** You can make images from 512x512 up to 2048x2048 (any aspect ratio is fine, it's about the total pixels).
|
| 21 |
+
- **Guidance Scale:** A guidance(CFG) scale between 3.0 and 5.0 is suggested.
|
| 22 |
+
- **Inference Steps:** Use 28 to 50 inference steps to generate images.
|
| 23 |
+
- **Prompt Style:** Longer, more detailed prompts work best (just like with Z-Image Turbo).
|
| 24 |
+
|
| 25 |
|
| 26 |
## References
|
| 27 |
- **Tongyi-MAI**: <https://huggingface.co/Tongyi-MAI>
|