Hermes Bot commited on
Commit ·
d2de2a3
1
Parent(s): 5c1ed6a
Revert repository to commit 1d4eb4e522c6572d69f5d06b1965a5ff48b664be
Browse files- ui/events/run_handlers.py +8 -19
- ui/shared/hires_fix_ui.py +1 -6
- ui/shared/img2img_ui.py +1 -5
- ui/shared/inpaint_ui.py +1 -6
- ui/shared/outpaint_ui.py +1 -6
- ui/shared/txt2img_ui.py +62 -18
ui/events/run_handlers.py
CHANGED
|
@@ -96,26 +96,15 @@ def create_run_event(prefix: str, task_type: str, ui_components: dict):
|
|
| 96 |
run_btn = ui_components.get(f'run_{prefix}') or ui_components.get(f'{prefix}_run_button')
|
| 97 |
res_gal = ui_components.get(f'result_{prefix}') or ui_components.get(f'{prefix}_output_gallery')
|
| 98 |
if run_btn and res_gal:
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
if not results:
|
| 106 |
-
return results, ""
|
| 107 |
-
# Load metadata from first generated PNG (parameters field)
|
| 108 |
-
try:
|
| 109 |
-
from PIL import Image
|
| 110 |
-
first_img_path = results[0]
|
| 111 |
-
with Image.open(first_img_path) as im:
|
| 112 |
-
meta = im.info.get('parameters', '')
|
| 113 |
-
except Exception as e:
|
| 114 |
-
meta = f"(failed to read metadata: {e})"
|
| 115 |
-
return results, meta
|
| 116 |
|
| 117 |
run_btn.click(
|
| 118 |
-
fn=
|
| 119 |
inputs=input_list_flat,
|
| 120 |
-
outputs=
|
| 121 |
)
|
|
|
|
| 96 |
run_btn = ui_components.get(f'run_{prefix}') or ui_components.get(f'{prefix}_run_button')
|
| 97 |
res_gal = ui_components.get(f'result_{prefix}') or ui_components.get(f'{prefix}_output_gallery')
|
| 98 |
if run_btn and res_gal:
|
| 99 |
+
outputs = [res_gal]
|
| 100 |
+
gallery_tab = ui_components.get('gallery')
|
| 101 |
+
# The global Gallery tab shows images from the output folder independently.
|
| 102 |
+
# Therefore we do NOT duplicate the result here.
|
| 103 |
+
# The Gallery component loads images via demo.load() on startup.
|
| 104 |
+
# No need to add it to the run button outputs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
run_btn.click(
|
| 107 |
+
fn=lambda *args, progress=gr.Progress(track_tqdm=True): generate_image_wrapper(create_ui_inputs_dict(*args), progress),
|
| 108 |
inputs=input_list_flat,
|
| 109 |
+
outputs=outputs
|
| 110 |
)
|
ui/shared/hires_fix_ui.py
CHANGED
|
@@ -85,12 +85,7 @@ def create_ui():
|
|
| 85 |
components[f'height_{prefix}'] = gr.State(value=512)
|
| 86 |
|
| 87 |
with gr.Column(scale=1):
|
| 88 |
-
|
| 89 |
-
with gr.Row():
|
| 90 |
-
components[f'result_{prefix}'] = gr.Gallery(label="Result", show_label=False, columns=1, object_fit="contain", height=610)
|
| 91 |
-
with gr.Row():
|
| 92 |
-
components[f'metadata_{prefix}'] = gr.Textbox(label="Generation info", lines=4, interactive=False)
|
| 93 |
-
|
| 94 |
|
| 95 |
|
| 96 |
components.update(create_lora_settings_ui(prefix))
|
|
|
|
| 85 |
components[f'height_{prefix}'] = gr.State(value=512)
|
| 86 |
|
| 87 |
with gr.Column(scale=1):
|
| 88 |
+
components[f'result_{prefix}'] = gr.Gallery(label="Result", show_label=False, columns=1, type="filepath", height=610)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
|
| 91 |
components.update(create_lora_settings_ui(prefix))
|
ui/shared/img2img_ui.py
CHANGED
|
@@ -66,11 +66,7 @@ def create_ui():
|
|
| 66 |
components[f'zero_gpu_{prefix}'] = gr.Number(label="ZeroGPU Duration (s)", value=None, placeholder="Default: 60s, Max: 120s", info="Optional: Set how long to reserve the GPU. Longer jobs may need more time.")
|
| 67 |
|
| 68 |
with gr.Column(scale=1):
|
| 69 |
-
|
| 70 |
-
with gr.Row():
|
| 71 |
-
components[f'result_{prefix}'] = gr.Gallery(label="Result", show_label=False, columns=1, object_fit="contain", height=505)
|
| 72 |
-
with gr.Row():
|
| 73 |
-
components[f'metadata_{prefix}'] = gr.Textbox(label="Generation info", lines=4, interactive=False)
|
| 74 |
|
| 75 |
|
| 76 |
components.update(create_lora_settings_ui(prefix))
|
|
|
|
| 66 |
components[f'zero_gpu_{prefix}'] = gr.Number(label="ZeroGPU Duration (s)", value=None, placeholder="Default: 60s, Max: 120s", info="Optional: Set how long to reserve the GPU. Longer jobs may need more time.")
|
| 67 |
|
| 68 |
with gr.Column(scale=1):
|
| 69 |
+
components[f'result_{prefix}'] = gr.Gallery(label="Result", show_label=False, columns=1, type="filepath", height=505)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
|
| 72 |
components.update(create_lora_settings_ui(prefix))
|
ui/shared/inpaint_ui.py
CHANGED
|
@@ -95,12 +95,7 @@ def create_ui():
|
|
| 95 |
components[f'height_{prefix}'] = gr.State(value=512)
|
| 96 |
|
| 97 |
with gr.Column(scale=1):
|
| 98 |
-
|
| 99 |
-
with gr.Row():
|
| 100 |
-
components[f'result_{prefix}'] = gr.Gallery(label="Result", show_label=False, columns=1, object_fit="contain", height=510)
|
| 101 |
-
with gr.Row():
|
| 102 |
-
components[f'metadata_{prefix}'] = gr.Textbox(label="Generation info", lines=4, interactive=False)
|
| 103 |
-
|
| 104 |
|
| 105 |
components[f'params_and_gallery_row_{prefix}'] = params_and_gallery_row
|
| 106 |
|
|
|
|
| 95 |
components[f'height_{prefix}'] = gr.State(value=512)
|
| 96 |
|
| 97 |
with gr.Column(scale=1):
|
| 98 |
+
components[f'result_{prefix}'] = gr.Gallery(label="Result", show_label=False, columns=1, type="filepath", height=510)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
components[f'params_and_gallery_row_{prefix}'] = params_and_gallery_row
|
| 101 |
|
ui/shared/outpaint_ui.py
CHANGED
|
@@ -81,12 +81,7 @@ def create_ui():
|
|
| 81 |
components[f'height_{prefix}'] = gr.State(value=512)
|
| 82 |
|
| 83 |
with gr.Column(scale=1):
|
| 84 |
-
|
| 85 |
-
with gr.Row():
|
| 86 |
-
components[f'result_{prefix}'] = gr.Gallery(label="Result", show_label=False, columns=1, object_fit="contain", height=685)
|
| 87 |
-
with gr.Row():
|
| 88 |
-
components[f'metadata_{prefix}'] = gr.Textbox(label="Generation info", lines=4, interactive=False)
|
| 89 |
-
|
| 90 |
|
| 91 |
|
| 92 |
components.update(create_lora_settings_ui(prefix))
|
|
|
|
| 81 |
components[f'height_{prefix}'] = gr.State(value=512)
|
| 82 |
|
| 83 |
with gr.Column(scale=1):
|
| 84 |
+
components[f'result_{prefix}'] = gr.Gallery(label="Result", show_label=False, columns=1, type="filepath", height=685)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
|
| 87 |
components.update(create_lora_settings_ui(prefix))
|
ui/shared/txt2img_ui.py
CHANGED
|
@@ -1,13 +1,15 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from core.settings import MODEL_MAP_CHECKPOINT
|
|
|
|
| 3 |
from .ui_components import (
|
| 4 |
-
|
| 5 |
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
|
| 6 |
create_conditioning_ui, create_vae_override_ui,
|
| 7 |
create_model_architecture_filter_ui, create_category_filter_ui,
|
| 8 |
create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
|
| 9 |
create_reference_latent_ui, create_hidream_o1_reference_ui,
|
| 10 |
-
create_pid_ui
|
|
|
|
| 11 |
)
|
| 12 |
|
| 13 |
def create_ui():
|
|
@@ -18,34 +20,76 @@ def create_ui():
|
|
| 18 |
with gr.Column():
|
| 19 |
components.update(create_model_architecture_filter_ui(prefix))
|
| 20 |
|
|
|
|
| 21 |
with gr.Row():
|
| 22 |
components.update(create_category_filter_ui(prefix))
|
| 23 |
components[f'base_model_{prefix}'] = gr.Dropdown(
|
| 24 |
-
label="Base Model",
|
| 25 |
-
choices=list(MODEL_MAP_CHECKPOINT.keys()),
|
| 26 |
-
value=list(MODEL_MAP_CHECKPOINT.keys())[0],
|
| 27 |
scale=3,
|
| 28 |
-
allow_custom_value=True
|
| 29 |
)
|
| 30 |
-
with gr.Column(scale=1):
|
| 31 |
components[f'run_{prefix}'] = gr.Button("Run", variant="primary")
|
| 32 |
|
|
|
|
| 33 |
components[f'prompt_{prefix}'] = gr.Text(label="Prompt", lines=3)
|
| 34 |
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=3)
|
| 35 |
|
|
|
|
| 36 |
with gr.Row():
|
| 37 |
-
#
|
| 38 |
-
with gr.Column(
|
| 39 |
-
|
| 40 |
-
components
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
with gr.Row():
|
| 44 |
-
components[f'
|
|
|
|
|
|
|
| 45 |
with gr.Row():
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
components.update(create_lora_settings_ui(prefix))
|
| 51 |
components.update(create_controlnet_ui(prefix))
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from core.settings import MODEL_MAP_CHECKPOINT, RESOLUTION_MAP
|
| 3 |
+
from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
|
| 4 |
from .ui_components import (
|
| 5 |
+
create_lora_settings_ui,
|
| 6 |
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
|
| 7 |
create_conditioning_ui, create_vae_override_ui,
|
| 8 |
create_model_architecture_filter_ui, create_category_filter_ui,
|
| 9 |
create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
|
| 10 |
create_reference_latent_ui, create_hidream_o1_reference_ui,
|
| 11 |
+
create_pid_ui,
|
| 12 |
+
DEFAULT_SAMPLER, DEFAULT_SCHEDULER, DEFAULT_STEPS, DEFAULT_CFG,
|
| 13 |
)
|
| 14 |
|
| 15 |
def create_ui():
|
|
|
|
| 20 |
with gr.Column():
|
| 21 |
components.update(create_model_architecture_filter_ui(prefix))
|
| 22 |
|
| 23 |
+
# Layout for model selection and run button
|
| 24 |
with gr.Row():
|
| 25 |
components.update(create_category_filter_ui(prefix))
|
| 26 |
components[f'base_model_{prefix}'] = gr.Dropdown(
|
| 27 |
+
label="Base Model",
|
| 28 |
+
choices=list(MODEL_MAP_CHECKPOINT.keys()),
|
| 29 |
+
value=list(MODEL_MAP_CHECKPOINT.keys())[0],
|
| 30 |
scale=3,
|
| 31 |
+
allow_custom_value=True,
|
| 32 |
)
|
| 33 |
+
with gr.Column(scale=1):
|
| 34 |
components[f'run_{prefix}'] = gr.Button("Run", variant="primary")
|
| 35 |
|
| 36 |
+
# Prompt fields
|
| 37 |
components[f'prompt_{prefix}'] = gr.Text(label="Prompt", lines=3)
|
| 38 |
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=3)
|
| 39 |
|
| 40 |
+
# Layout: left column – parameter blocks; right column – result gallery (same height as left)
|
| 41 |
with gr.Row():
|
| 42 |
+
# LEFT: all parameter blocks stacked vertically
|
| 43 |
+
with gr.Column():
|
| 44 |
+
# Aspect Ratio block
|
| 45 |
+
components[f'aspect_ratio_{prefix}'] = gr.Dropdown(
|
| 46 |
+
label="Aspect Ratio",
|
| 47 |
+
choices=list(RESOLUTION_MAP.get('sdxl', {}).keys()),
|
| 48 |
+
value="1:1 (Square)",
|
| 49 |
+
interactive=True,
|
| 50 |
+
allow_custom_value=True,
|
| 51 |
+
)
|
| 52 |
+
# Width & Height block
|
| 53 |
with gr.Row():
|
| 54 |
+
components[f'width_{prefix}'] = gr.Number(label="Width", value=1024, interactive=True)
|
| 55 |
+
components[f'height_{prefix}'] = gr.Number(label="Height", value=1024, interactive=True)
|
| 56 |
+
# Sampler & Scheduler block
|
| 57 |
with gr.Row():
|
| 58 |
+
components[f'sampler_{prefix}'] = gr.Dropdown(
|
| 59 |
+
label="Sampler",
|
| 60 |
+
choices=SAMPLER_CHOICES,
|
| 61 |
+
value=DEFAULT_SAMPLER if DEFAULT_SAMPLER in SAMPLER_CHOICES else (SAMPLER_CHOICES[0] if SAMPLER_CHOICES else 'euler')
|
| 62 |
+
)
|
| 63 |
+
components[f'scheduler_{prefix}'] = gr.Dropdown(
|
| 64 |
+
label="Scheduler",
|
| 65 |
+
choices=SCHEDULER_CHOICES,
|
| 66 |
+
value=DEFAULT_SCHEDULER if DEFAULT_SCHEDULER in SCHEDULER_CHOICES else (SCHEDULER_CHOICES[0] if SCHEDULER_CHOICES else 'simple')
|
| 67 |
+
)
|
| 68 |
+
# Steps & CFG Scale block
|
| 69 |
+
with gr.Row():
|
| 70 |
+
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=DEFAULT_STEPS)
|
| 71 |
+
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=DEFAULT_CFG)
|
| 72 |
+
# Seed & Batch Size block
|
| 73 |
+
with gr.Row():
|
| 74 |
+
components[f'seed_{prefix}'] = gr.Number(label="Seed (-1 for random)", value=-1, precision=0)
|
| 75 |
+
components[f'batch_size_{prefix}'] = gr.Slider(label="Batch Size", minimum=1, maximum=16, step=1, value=1)
|
| 76 |
+
# ZeroGPU Duration block
|
| 77 |
+
components[f'zero_gpu_{prefix}'] = gr.Number(
|
| 78 |
+
label="ZeroGPU Duration (s)",
|
| 79 |
+
value=None,
|
| 80 |
+
placeholder="Default: 60s, Max: 120s",
|
| 81 |
+
info="Optional: Set how long to reserve the GPU."
|
| 82 |
+
)
|
| 83 |
+
# RIGHT: result gallery – height matches combined left column height
|
| 84 |
+
with gr.Column():
|
| 85 |
+
components[f'result_{prefix}'] = gr.Gallery(
|
| 86 |
+
label="Result",
|
| 87 |
+
show_label=False,
|
| 88 |
+
columns=2,
|
| 89 |
+
type="filepath",
|
| 90 |
+
height=627
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
|
| 94 |
components.update(create_lora_settings_ui(prefix))
|
| 95 |
components.update(create_controlnet_ui(prefix))
|