Update app.py
Browse files
app.py
CHANGED
|
@@ -309,13 +309,7 @@ loras = [
|
|
| 309 |
"weights": "50s_western_z_100.safetensors",
|
| 310 |
"trigger_word": "50s_western"
|
| 311 |
},
|
| 312 |
-
|
| 313 |
-
"image": "https://huggingface.co/Sumitc13/Z-image-Turbo_LogC4_lora/resolve/main/images/1764464517272__000005000_1.jpg",
|
| 314 |
-
"title": "LogC4",
|
| 315 |
-
"repo": "Sumitc13/Z-image-Turbo_LogC4_lora", #30
|
| 316 |
-
"weights": "z-image-logc4_000005000.safetensors",
|
| 317 |
-
"trigger_word": "LogC4"
|
| 318 |
-
},
|
| 319 |
{
|
| 320 |
"image": "https://huggingface.co/neph1/80s_scifi_lora_zit/resolve/main/images/ComfyUI_10288_.png",
|
| 321 |
"title": "80s Scifi",
|
|
@@ -587,20 +581,27 @@ def update_selection(evt: gr.SelectData, width, height):
|
|
| 587 |
updated_text = f"### Selected: Local LoRA - {selected_lora['title']} ✅"
|
| 588 |
else:
|
| 589 |
updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo}) ✅"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 590 |
if "aspect" in selected_lora:
|
| 591 |
if selected_lora["aspect"] == "portrait":
|
|
|
|
| 592 |
width = 768
|
| 593 |
-
height =
|
| 594 |
elif selected_lora["aspect"] == "landscape":
|
| 595 |
-
|
|
|
|
| 596 |
height = 768
|
| 597 |
-
|
| 598 |
-
width = 1024
|
| 599 |
-
height = 1024
|
| 600 |
return (
|
| 601 |
gr.update(placeholder=new_placeholder),
|
| 602 |
updated_text,
|
| 603 |
evt.index,
|
|
|
|
| 604 |
width,
|
| 605 |
height,
|
| 606 |
)
|
|
@@ -806,24 +807,61 @@ with gr.Blocks(title="Z-IMAGE GEN/LORA", delete_cache=(60, 60)) as demo:
|
|
| 806 |
progress_bar = gr.Markdown(elem_id="progress",visible=False)
|
| 807 |
result = gr.Image(label="Generated Image", format="png", height=630)
|
| 808 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 809 |
with gr.Row():
|
| 810 |
-
with gr.Accordion("Advanced Settings", open=
|
| 811 |
with gr.Row():
|
| 812 |
input_image = gr.Image(label="Input image (Ignored for Z-Image-Turbo)", type="filepath", visible=False)
|
| 813 |
image_strength = gr.Slider(label="Denoise Strength", info="Ignored for Z-Image-Turbo", minimum=0.1, maximum=1.0, step=0.01, value=0.75, visible=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 814 |
with gr.Column():
|
| 815 |
with gr.Row():
|
| 816 |
cfg_scale = gr.Slider(label="CFG Scale", info="Forced to 0.0 for Turbo", minimum=0, maximum=20, step=0.5, value=0.0, interactive=False)
|
| 817 |
steps = gr.Slider(label="Steps", minimum=1, maximum=50, step=1, value=25)
|
| 818 |
|
| 819 |
-
with gr.Row():
|
| 820 |
-
width = gr.Slider(label="Width", minimum=256, maximum=1536, step=64, value=1536)
|
| 821 |
-
height = gr.Slider(label="Height", minimum=256, maximum=1536, step=64, value=1536)
|
| 822 |
-
|
| 823 |
with gr.Row():
|
| 824 |
randomize_seed = gr.Checkbox(True, label="Randomize seed")
|
| 825 |
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0, randomize=True)
|
| 826 |
lora_scale = gr.Slider(label="LoRA Scale", minimum=0, maximum=3, step=0.01, value=0.95)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 827 |
|
| 828 |
# Footer
|
| 829 |
gr.HTML("""
|
|
@@ -838,7 +876,7 @@ with gr.Blocks(title="Z-IMAGE GEN/LORA", delete_cache=(60, 60)) as demo:
|
|
| 838 |
gallery.select(
|
| 839 |
update_selection,
|
| 840 |
inputs=[width, height],
|
| 841 |
-
outputs=[prompt, selected_info, selected_index, width, height]
|
| 842 |
)
|
| 843 |
custom_lora.input(
|
| 844 |
add_custom_lora,
|
|
|
|
| 309 |
"weights": "50s_western_z_100.safetensors",
|
| 310 |
"trigger_word": "50s_western"
|
| 311 |
},
|
| 312 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
{
|
| 314 |
"image": "https://huggingface.co/neph1/80s_scifi_lora_zit/resolve/main/images/ComfyUI_10288_.png",
|
| 315 |
"title": "80s Scifi",
|
|
|
|
| 581 |
updated_text = f"### Selected: Local LoRA - {selected_lora['title']} ✅"
|
| 582 |
else:
|
| 583 |
updated_text = f"### Selected: [{lora_repo}](https://huggingface.co/{lora_repo}) ✅"
|
| 584 |
+
|
| 585 |
+
# Default aspect ratio
|
| 586 |
+
aspect = "1:1 (Instagram Square)"
|
| 587 |
+
width = 1024
|
| 588 |
+
height = 1024
|
| 589 |
+
|
| 590 |
if "aspect" in selected_lora:
|
| 591 |
if selected_lora["aspect"] == "portrait":
|
| 592 |
+
aspect = "9:16 (Instagram Reels/TikTok/Shorts)"
|
| 593 |
width = 768
|
| 594 |
+
height = 1344
|
| 595 |
elif selected_lora["aspect"] == "landscape":
|
| 596 |
+
aspect = "16:9 (YouTube/Twitter/X)"
|
| 597 |
+
width = 1344
|
| 598 |
height = 768
|
| 599 |
+
|
|
|
|
|
|
|
| 600 |
return (
|
| 601 |
gr.update(placeholder=new_placeholder),
|
| 602 |
updated_text,
|
| 603 |
evt.index,
|
| 604 |
+
aspect,
|
| 605 |
width,
|
| 606 |
height,
|
| 607 |
)
|
|
|
|
| 807 |
progress_bar = gr.Markdown(elem_id="progress",visible=False)
|
| 808 |
result = gr.Image(label="Generated Image", format="png", height=630)
|
| 809 |
|
| 810 |
+
# SNS Aspect Ratio Presets
|
| 811 |
+
ASPECT_RATIOS = {
|
| 812 |
+
"1:1 (Instagram Square)": (1024, 1024),
|
| 813 |
+
"9:16 (Instagram Reels/TikTok/Shorts)": (768, 1344),
|
| 814 |
+
"16:9 (YouTube/Twitter/X)": (1344, 768),
|
| 815 |
+
"4:5 (Instagram Portrait)": (896, 1120),
|
| 816 |
+
"5:4 (Instagram Landscape)": (1120, 896),
|
| 817 |
+
"3:4 (Portrait Photo)": (896, 1152),
|
| 818 |
+
"4:3 (Landscape Photo)": (1152, 896),
|
| 819 |
+
"2:3 (Pinterest)": (832, 1248),
|
| 820 |
+
"3:2 (Classic Photo)": (1248, 832),
|
| 821 |
+
"21:9 (Cinematic Ultra-wide)": (1344, 576),
|
| 822 |
+
"9:21 (Tall Banner)": (576, 1344),
|
| 823 |
+
}
|
| 824 |
+
|
| 825 |
+
def update_size(aspect_ratio):
|
| 826 |
+
width, height = ASPECT_RATIOS.get(aspect_ratio, (1024, 1024))
|
| 827 |
+
return width, height
|
| 828 |
+
|
| 829 |
with gr.Row():
|
| 830 |
+
with gr.Accordion("⚙️ Advanced Settings", open=True):
|
| 831 |
with gr.Row():
|
| 832 |
input_image = gr.Image(label="Input image (Ignored for Z-Image-Turbo)", type="filepath", visible=False)
|
| 833 |
image_strength = gr.Slider(label="Denoise Strength", info="Ignored for Z-Image-Turbo", minimum=0.1, maximum=1.0, step=0.01, value=0.75, visible=False)
|
| 834 |
+
|
| 835 |
+
gr.HTML('<div class="info-box">📐 <b>Image Size</b> - Select aspect ratio for different platforms</div>')
|
| 836 |
+
|
| 837 |
+
with gr.Row():
|
| 838 |
+
aspect_ratio = gr.Dropdown(
|
| 839 |
+
choices=list(ASPECT_RATIOS.keys()),
|
| 840 |
+
value="1:1 (Instagram Square)",
|
| 841 |
+
label="📱 Aspect Ratio (SNS Presets)",
|
| 842 |
+
info="Choose the best ratio for your target platform"
|
| 843 |
+
)
|
| 844 |
+
|
| 845 |
+
with gr.Row():
|
| 846 |
+
width = gr.Slider(label="Width", minimum=256, maximum=1536, step=64, value=1024)
|
| 847 |
+
height = gr.Slider(label="Height", minimum=256, maximum=1536, step=64, value=1024)
|
| 848 |
+
|
| 849 |
with gr.Column():
|
| 850 |
with gr.Row():
|
| 851 |
cfg_scale = gr.Slider(label="CFG Scale", info="Forced to 0.0 for Turbo", minimum=0, maximum=20, step=0.5, value=0.0, interactive=False)
|
| 852 |
steps = gr.Slider(label="Steps", minimum=1, maximum=50, step=1, value=25)
|
| 853 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 854 |
with gr.Row():
|
| 855 |
randomize_seed = gr.Checkbox(True, label="Randomize seed")
|
| 856 |
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0, randomize=True)
|
| 857 |
lora_scale = gr.Slider(label="LoRA Scale", minimum=0, maximum=3, step=0.01, value=0.95)
|
| 858 |
+
|
| 859 |
+
# Connect aspect ratio dropdown to width/height sliders
|
| 860 |
+
aspect_ratio.change(
|
| 861 |
+
fn=update_size,
|
| 862 |
+
inputs=[aspect_ratio],
|
| 863 |
+
outputs=[width, height]
|
| 864 |
+
)
|
| 865 |
|
| 866 |
# Footer
|
| 867 |
gr.HTML("""
|
|
|
|
| 876 |
gallery.select(
|
| 877 |
update_selection,
|
| 878 |
inputs=[width, height],
|
| 879 |
+
outputs=[prompt, selected_info, selected_index, aspect_ratio, width, height]
|
| 880 |
)
|
| 881 |
custom_lora.input(
|
| 882 |
add_custom_lora,
|