Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -598,80 +598,72 @@ def infer_upscale(
|
|
598 |
|
599 |
|
600 |
|
601 |
-
with gr.Blocks(theme=
|
602 |
-
|
603 |
loras_state = gr.State(loras)
|
604 |
selected_indices = gr.State([])
|
|
|
605 |
with gr.Row():
|
606 |
with gr.Column(scale=3):
|
607 |
prompt = gr.Textbox(label="Prompt", lines=1, placeholder="Type a prompt after selecting a LoRA")
|
608 |
with gr.Column(scale=1):
|
609 |
-
generate_button = gr.Button("Generate", variant="primary"
|
610 |
-
|
611 |
-
with gr.Row(
|
612 |
with gr.Column(scale=1, min_width=25):
|
613 |
-
randomize_button = gr.Button("🎲", variant="secondary"
|
614 |
with gr.Column(scale=8):
|
615 |
with gr.Row():
|
616 |
with gr.Column(scale=0, min_width=50):
|
617 |
-
lora_image_1 = gr.Image(label="LoRA 1 Image", interactive=False,
|
618 |
with gr.Column(scale=3, min_width=100):
|
619 |
selected_info_1 = gr.Markdown("Select a LoRA 1")
|
620 |
with gr.Column(scale=5, min_width=50):
|
621 |
lora_scale_1 = gr.Slider(label="LoRA 1 Scale", minimum=0, maximum=3, step=0.01, value=1.15)
|
622 |
-
|
623 |
-
remove_button_1 = gr.Button("Remove", size="sm")
|
624 |
with gr.Column(scale=8):
|
625 |
with gr.Row():
|
626 |
with gr.Column(scale=0, min_width=50):
|
627 |
-
lora_image_2 = gr.Image(label="LoRA 2 Image", interactive=False,
|
628 |
with gr.Column(scale=3, min_width=100):
|
629 |
selected_info_2 = gr.Markdown("Select a LoRA 2")
|
630 |
with gr.Column(scale=5, min_width=50):
|
631 |
lora_scale_2 = gr.Slider(label="LoRA 2 Scale", minimum=0, maximum=3, step=0.01, value=1.15)
|
632 |
-
|
633 |
-
|
634 |
with gr.Row():
|
635 |
with gr.Column():
|
636 |
with gr.Group():
|
637 |
-
with gr.Row(
|
638 |
-
custom_lora = gr.Textbox(label="Custom LoRA", info="LoRA Hugging Face path or *.safetensors public URL", placeholder="ginipick/flux-lora-eric-cat", scale=3
|
639 |
-
add_custom_lora_button = gr.Button("Add Custom LoRA",
|
640 |
remove_custom_lora_button = gr.Button("Remove Custom LoRA", visible=False)
|
641 |
-
gr.Markdown("[Check the list of FLUX LoRAs](https://huggingface.co/models?other=base_model:adapter:black-forest-labs/FLUX.1-dev)"
|
642 |
gallery = gr.Gallery(
|
643 |
[(item["image"], item["title"]) for item in loras],
|
644 |
label="Or pick from the LoRA Explorer gallery",
|
645 |
-
allow_preview=False,
|
646 |
columns=4,
|
647 |
-
elem_id="gallery"
|
648 |
)
|
649 |
with gr.Column():
|
650 |
-
progress_bar = gr.Markdown(
|
651 |
result = gr.Image(label="Generated Image", interactive=False)
|
652 |
with gr.Accordion("History", open=False):
|
653 |
history_gallery = gr.Gallery(label="History", columns=6, object_fit="contain", interactive=False)
|
654 |
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
with gr.Row():
|
671 |
-
randomize_seed = gr.Checkbox(True, label="Randomize seed")
|
672 |
-
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0, randomize=True)
|
673 |
-
|
674 |
-
# 업스케일 관련 UI 추가
|
675 |
with gr.Row():
|
676 |
upscale_button = gr.Button("Upscale")
|
677 |
|
@@ -679,44 +671,21 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, delete_cache=(60, 3600)) as a
|
|
679 |
with gr.Column(scale=4):
|
680 |
upscale_input = gr.Image(label="Input Image for Upscaling", type="pil")
|
681 |
with gr.Column(scale=1):
|
682 |
-
upscale_steps = gr.Slider(
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
step=1,
|
687 |
-
value=28,
|
688 |
-
)
|
689 |
-
upscale_factor = gr.Slider(
|
690 |
-
label="Upscale Factor",
|
691 |
-
minimum=1,
|
692 |
-
maximum=4,
|
693 |
-
step=1,
|
694 |
-
value=4,
|
695 |
-
)
|
696 |
-
controlnet_conditioning_scale = gr.Slider(
|
697 |
-
label="Controlnet Conditioning Scale",
|
698 |
-
minimum=0.1,
|
699 |
-
maximum=1.5,
|
700 |
-
step=0.1,
|
701 |
-
value=0.6,
|
702 |
-
)
|
703 |
-
upscale_seed = gr.Slider(
|
704 |
-
label="Seed for Upscaling",
|
705 |
-
minimum=0,
|
706 |
-
maximum=MAX_SEED,
|
707 |
-
step=1,
|
708 |
-
value=42,
|
709 |
-
)
|
710 |
upscale_randomize_seed = gr.Checkbox(label="Randomize seed for Upscaling", value=True)
|
711 |
|
712 |
with gr.Row():
|
713 |
-
upscale_result =
|
714 |
-
|
715 |
|
|
|
716 |
gallery.select(
|
717 |
update_selection,
|
718 |
inputs=[selected_indices, loras_state, width, height],
|
719 |
-
outputs=[prompt, selected_info_1, selected_info_2, selected_indices, lora_scale_1, lora_scale_2, width, height, lora_image_1, lora_image_2]
|
|
|
720 |
remove_button_1.click(
|
721 |
remove_lora_1,
|
722 |
inputs=[selected_indices, loras_state],
|
@@ -742,21 +711,17 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css, delete_cache=(60, 3600)) as a
|
|
742 |
inputs=[selected_indices, loras_state],
|
743 |
outputs=[loras_state, gallery, selected_info_1, selected_info_2, selected_indices, lora_scale_1, lora_scale_2, lora_image_1, lora_image_2]
|
744 |
)
|
745 |
-
|
746 |
-
|
747 |
-
[
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
upscale_factor,
|
755 |
-
controlnet_conditioning_scale,
|
756 |
-
],
|
757 |
-
outputs=upscale_result,
|
758 |
)
|
759 |
|
760 |
-
|
761 |
-
app.queue()
|
762 |
-
app.launch()
|
|
|
598 |
|
599 |
|
600 |
|
601 |
+
with gr.Blocks(theme=gr.themes.Default(), css=css) as app:
|
|
|
602 |
loras_state = gr.State(loras)
|
603 |
selected_indices = gr.State([])
|
604 |
+
|
605 |
with gr.Row():
|
606 |
with gr.Column(scale=3):
|
607 |
prompt = gr.Textbox(label="Prompt", lines=1, placeholder="Type a prompt after selecting a LoRA")
|
608 |
with gr.Column(scale=1):
|
609 |
+
generate_button = gr.Button("Generate", variant="primary")
|
610 |
+
|
611 |
+
with gr.Row():
|
612 |
with gr.Column(scale=1, min_width=25):
|
613 |
+
randomize_button = gr.Button("🎲", variant="secondary")
|
614 |
with gr.Column(scale=8):
|
615 |
with gr.Row():
|
616 |
with gr.Column(scale=0, min_width=50):
|
617 |
+
lora_image_1 = gr.Image(label="LoRA 1 Image", interactive=False, width=50, height=50)
|
618 |
with gr.Column(scale=3, min_width=100):
|
619 |
selected_info_1 = gr.Markdown("Select a LoRA 1")
|
620 |
with gr.Column(scale=5, min_width=50):
|
621 |
lora_scale_1 = gr.Slider(label="LoRA 1 Scale", minimum=0, maximum=3, step=0.01, value=1.15)
|
622 |
+
remove_button_1 = gr.Button("Remove", size="sm")
|
|
|
623 |
with gr.Column(scale=8):
|
624 |
with gr.Row():
|
625 |
with gr.Column(scale=0, min_width=50):
|
626 |
+
lora_image_2 = gr.Image(label="LoRA 2 Image", interactive=False, width=50, height=50)
|
627 |
with gr.Column(scale=3, min_width=100):
|
628 |
selected_info_2 = gr.Markdown("Select a LoRA 2")
|
629 |
with gr.Column(scale=5, min_width=50):
|
630 |
lora_scale_2 = gr.Slider(label="LoRA 2 Scale", minimum=0, maximum=3, step=0.01, value=1.15)
|
631 |
+
remove_button_2 = gr.Button("Remove", size="sm")
|
632 |
+
|
633 |
with gr.Row():
|
634 |
with gr.Column():
|
635 |
with gr.Group():
|
636 |
+
with gr.Row():
|
637 |
+
custom_lora = gr.Textbox(label="Custom LoRA", info="LoRA Hugging Face path or *.safetensors public URL", placeholder="ginipick/flux-lora-eric-cat", scale=3)
|
638 |
+
add_custom_lora_button = gr.Button("Add Custom LoRA", scale=2)
|
639 |
remove_custom_lora_button = gr.Button("Remove Custom LoRA", visible=False)
|
640 |
+
gr.Markdown("[Check the list of FLUX LoRAs](https://huggingface.co/models?other=base_model:adapter:black-forest-labs/FLUX.1-dev)")
|
641 |
gallery = gr.Gallery(
|
642 |
[(item["image"], item["title"]) for item in loras],
|
643 |
label="Or pick from the LoRA Explorer gallery",
|
|
|
644 |
columns=4,
|
|
|
645 |
)
|
646 |
with gr.Column():
|
647 |
+
progress_bar = gr.Markdown(visible=False)
|
648 |
result = gr.Image(label="Generated Image", interactive=False)
|
649 |
with gr.Accordion("History", open=False):
|
650 |
history_gallery = gr.Gallery(label="History", columns=6, object_fit="contain", interactive=False)
|
651 |
|
652 |
+
with gr.Accordion("Advanced Settings", open=False):
|
653 |
+
with gr.Row():
|
654 |
+
input_image = gr.Image(label="Input image", type="filepath")
|
655 |
+
image_strength = gr.Slider(label="Denoise Strength", info="Lower means more image influence", minimum=0.1, maximum=1.0, step=0.01, value=0.75)
|
656 |
+
with gr.Row():
|
657 |
+
cfg_scale = gr.Slider(label="CFG Scale", minimum=1, maximum=20, step=0.5, value=3.5)
|
658 |
+
steps = gr.Slider(label="Steps", minimum=1, maximum=50, step=1, value=28)
|
659 |
+
with gr.Row():
|
660 |
+
width = gr.Slider(label="Width", minimum=256, maximum=1536, step=64, value=1024)
|
661 |
+
height = gr.Slider(label="Height", minimum=256, maximum=1536, step=64, value=1024)
|
662 |
+
with gr.Row():
|
663 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
664 |
+
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0, randomize=True)
|
665 |
+
|
666 |
+
# Upscale related UI
|
|
|
|
|
|
|
|
|
|
|
667 |
with gr.Row():
|
668 |
upscale_button = gr.Button("Upscale")
|
669 |
|
|
|
671 |
with gr.Column(scale=4):
|
672 |
upscale_input = gr.Image(label="Input Image for Upscaling", type="pil")
|
673 |
with gr.Column(scale=1):
|
674 |
+
upscale_steps = gr.Slider(label="Number of Inference Steps for Upscaling", minimum=8, maximum=50, step=1, value=28)
|
675 |
+
upscale_factor = gr.Slider(label="Upscale Factor", minimum=1, maximum=4, step=1, value=4)
|
676 |
+
controlnet_conditioning_scale = gr.Slider(label="Controlnet Conditioning Scale", minimum=0.1, maximum=1.5, step=0.1, value=0.6)
|
677 |
+
upscale_seed = gr.Slider(label="Seed for Upscaling", minimum=0, maximum=MAX_SEED, step=1, value=42)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
678 |
upscale_randomize_seed = gr.Checkbox(label="Randomize seed for Upscaling", value=True)
|
679 |
|
680 |
with gr.Row():
|
681 |
+
upscale_result = gr.Image(label="Input / Output for Upscaling", type="pil", interactive=True)
|
|
|
682 |
|
683 |
+
# Event handlers
|
684 |
gallery.select(
|
685 |
update_selection,
|
686 |
inputs=[selected_indices, loras_state, width, height],
|
687 |
+
outputs=[prompt, selected_info_1, selected_info_2, selected_indices, lora_scale_1, lora_scale_2, width, height, lora_image_1, lora_image_2]
|
688 |
+
)
|
689 |
remove_button_1.click(
|
690 |
remove_lora_1,
|
691 |
inputs=[selected_indices, loras_state],
|
|
|
711 |
inputs=[selected_indices, loras_state],
|
712 |
outputs=[loras_state, gallery, selected_info_1, selected_info_2, selected_indices, lora_scale_1, lora_scale_2, lora_image_1, lora_image_2]
|
713 |
)
|
714 |
+
generate_button.click(
|
715 |
+
run_lora,
|
716 |
+
inputs=[prompt, input_image, image_strength, cfg_scale, steps, selected_indices, lora_scale_1, lora_scale_2, randomize_seed, seed, width, height, loras_state],
|
717 |
+
outputs=[result, seed, progress_bar]
|
718 |
+
)
|
719 |
+
upscale_button.click(
|
720 |
+
infer_upscale,
|
721 |
+
inputs=[upscale_seed, upscale_randomize_seed, upscale_input, upscale_steps, upscale_factor, controlnet_conditioning_scale],
|
722 |
+
outputs=upscale_result
|
|
|
|
|
|
|
|
|
723 |
)
|
724 |
|
725 |
+
if __name__ == "__main__":
|
726 |
+
app.queue(concurrency_count=3, max_size=20)
|
727 |
+
app.launch(debug=True)
|