File size: 6,426 Bytes
0516635 dd0ca3b 0516635 dd0ca3b 967a8ff 8a95959 0516635 dd0ca3b 0516635 967a8ff 0516635 967a8ff 0516635 967a8ff 0516635 95b4e48 0516635 dd0ca3b 0516635 dd0ca3b 0516635 dd0ca3b 0516635 967a8ff 0516635 967a8ff 0516635 967a8ff 4f64752 dd0ca3b 967a8ff 0516635 967a8ff 4f64752 d018eec 7d913cb de5b1cc 1634090 8a95959 9ba23bd 967a8ff 0516635 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | import gradio as gr
from core.settings import MODEL_MAP_CHECKPOINT, MODEL_DEFAULTS_CONFIG
from comfy_integration.nodes import SAMPLER_CHOICES, SCHEDULER_CHOICES
from .ui_components import (
create_lora_settings_ui,
create_controlnet_ui, create_anima_controlnet_lllite_ui, create_diffsynth_controlnet_ui, create_krea2_controlnet_ui, create_ipadapter_ui, create_embedding_ui,
create_conditioning_ui, create_vae_override_ui,
create_model_architecture_filter_ui, create_category_filter_ui,
create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
create_reference_latent_ui, create_hidream_o1_reference_ui, create_joyai_reference_ui, create_reference_image_ui, create_krea2_identity_edit_ui, create_krea2_reference_edit_ui, create_qwen_image_edit_ui, create_boogu_edit_ui
)
default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})
DEFAULT_STEPS = default_vals.get('steps', 20)
DEFAULT_CFG = default_vals.get('cfg', 5.0)
DEFAULT_SAMPLER = default_vals.get('sampler_name', 'euler')
DEFAULT_SCHEDULER = default_vals.get('scheduler', 'simple')
DEFAULT_POS_PROMPT = default_vals.get('positive_prompt', '')
DEFAULT_NEG_PROMPT = default_vals.get('negative_prompt', '')
def create_ui():
prefix = "hires_fix"
components = {}
with gr.Column():
components.update(create_model_architecture_filter_ui(prefix))
with gr.Row():
components.update(create_category_filter_ui(prefix))
components[f'base_model_{prefix}'] = gr.Dropdown(
label="Base Model",
choices=list(MODEL_MAP_CHECKPOINT.keys()),
value=list(MODEL_MAP_CHECKPOINT.keys())[0],
scale=3,
allow_custom_value=True
)
with gr.Column(scale=1):
components[f'run_{prefix}'] = gr.Button("Run Hires. Fix", variant="primary")
with gr.Row():
with gr.Column(scale=1):
components[f'input_image_{prefix}'] = gr.Image(type="pil", label="Input Image (No Scaling)", height=255)
with gr.Column(scale=2):
components[f'prompt_{prefix}'] = gr.Text(label="Prompt", lines=3, value=DEFAULT_POS_PROMPT)
components[f'neg_prompt_{prefix}'] = gr.Text(label="Negative prompt", lines=3, value=DEFAULT_NEG_PROMPT)
with gr.Row():
with gr.Column(scale=1):
with gr.Row():
components[f'hires_upscaler_{prefix}'] = gr.Dropdown(
label="Upscaler",
choices=["nearest-exact", "bilinear", "area", "bicubic", "bislerp"],
value="nearest-exact"
)
components[f'hires_scale_by_{prefix}'] = gr.Slider(
label="Upscale by", minimum=1.0, maximum=4.0, step=0.1, value=1.5
)
with gr.Row():
components[f'denoise_{prefix}'] = gr.Slider(label="Denoise Strength", minimum=0.0, maximum=1.0, step=0.01, value=0.55)
with gr.Row():
components[f'sampler_{prefix}'] = gr.Dropdown(
label="Sampler",
choices=SAMPLER_CHOICES,
value=DEFAULT_SAMPLER if DEFAULT_SAMPLER in SAMPLER_CHOICES else (SAMPLER_CHOICES[0] if SAMPLER_CHOICES else 'euler')
)
components[f'scheduler_{prefix}'] = gr.Dropdown(
label="Scheduler",
choices=SCHEDULER_CHOICES,
value=DEFAULT_SCHEDULER if DEFAULT_SCHEDULER in SCHEDULER_CHOICES else (SCHEDULER_CHOICES[0] if SCHEDULER_CHOICES else 'simple')
)
with gr.Row():
components[f'steps_{prefix}'] = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=DEFAULT_STEPS)
components[f'cfg_{prefix}'] = gr.Slider(label="CFG Scale", minimum=1.0, maximum=20.0, step=0.1, value=DEFAULT_CFG)
with gr.Row():
components[f'seed_{prefix}'] = gr.Number(label="Seed (-1 for random)", value=-1, precision=0)
components[f'batch_size_{prefix}'] = gr.Slider(label="Batch Size", minimum=1, maximum=16, step=1, value=1)
with gr.Row():
components[f'guidance_{prefix}'] = gr.Slider(label="Guidance (FLUX)", minimum=1.0, maximum=10.0, step=0.1, value=3.5, visible=False, interactive=True)
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.")
components[f'width_{prefix}'] = gr.State(value=512)
components[f'height_{prefix}'] = gr.State(value=512)
with gr.Column(scale=1):
components[f'result_{prefix}'] = gr.Gallery(label="Result", show_label=False, columns=1, object_fit="contain", height=610)
components.update(create_lora_settings_ui(prefix))
components.update(create_controlnet_ui(prefix))
components.update(create_anima_controlnet_lllite_ui(prefix))
components.update(create_diffsynth_controlnet_ui(prefix))
components.update(create_krea2_controlnet_ui(prefix))
components.update(create_ipadapter_ui(prefix))
components.update(create_flux1_ipadapter_ui(prefix))
components.update(create_sd3_ipadapter_ui(prefix))
components.update(create_style_ui(prefix))
components.update(create_embedding_ui(prefix))
components.update(create_conditioning_ui(prefix))
components.update(create_reference_latent_ui(prefix))
components.update(create_hidream_o1_reference_ui(prefix))
components.update(create_joyai_reference_ui(prefix))
components.update(create_krea2_identity_edit_ui(prefix))
components.update(create_krea2_reference_edit_ui(prefix))
components.update(create_qwen_image_edit_ui(prefix))
components.update(create_boogu_edit_ui(prefix))
components.update(create_reference_image_ui(prefix))
components.update(create_vae_override_ui(prefix))
return components |