From 7d5b31bb78a89e7acf667fdd4352f519a9ada2ca Mon Sep 17 00:00:00 2001 From: DenOfEquity <166248528+DenOfEquity@users.noreply.github.com> Date: Sun, 8 Sep 2024 21:08:44 +0100 Subject: [PATCH] restore use of Settings for hiresfix options (#1706) Re-enables *hires_fix_show_sampler* and *hires_fix_show_prompts* user-configurable settings. Also corrects the reported result width x height; now rounded down to multiple of 8. #1247 --- modules/ui.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/ui.py b/modules/ui.py index 12ff507d..2193eb35 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -96,7 +96,13 @@ def calc_resolution_hires(enable, width, height, hr_scale, hr_resize_x, hr_resiz p = processing.StableDiffusionProcessingTxt2Img(width=width, height=height, enable_hr=True, hr_scale=hr_scale, hr_resize_x=hr_resize_x, hr_resize_y=hr_resize_y) p.calculate_target_resolution() - return f"from {p.width}x{p.height} to {p.hr_resize_x or p.hr_upscale_to_x}x{p.hr_resize_y or p.hr_upscale_to_y}" + new_width = p.hr_resize_x or p.hr_upscale_to_x + new_height = p.hr_resize_y or p.hr_upscale_to_y + + new_width -= new_width % 8 # note: hardcoded latent size 8 + new_height -= new_height % 8 + + return f"from {p.width}x{p.height} to {new_width}x{new_height}" def resize_from_to_html(width, height, scale_by): @@ -332,7 +338,7 @@ def create_ui(): hr_resize_x = gr.Slider(minimum=0, maximum=2048, step=8, label="Resize width to", value=0, elem_id="txt2img_hr_resize_x") hr_resize_y = gr.Slider(minimum=0, maximum=2048, step=8, label="Resize height to", value=0, elem_id="txt2img_hr_resize_y") - with FormRow(elem_id="txt2img_hires_fix_row3", variant="compact") as hr_sampler_container: + with FormRow(elem_id="txt2img_hires_fix_row3", variant="compact", visible=shared.opts.hires_fix_show_sampler) as hr_sampler_container: hr_checkpoint_name = gr.Dropdown(label='Checkpoint', elem_id="hr_checkpoint", choices=["Use same checkpoint"], value="Use same checkpoint", visible=False, interactive=False) # create_refresh_button(hr_checkpoint_name, modules.sd_models.list_models, lambda: {"choices": ["Use same checkpoint"] + modules.sd_models.checkpoint_tiles(use_short=True)}, "hr_checkpoint_refresh") @@ -340,7 +346,7 @@ def create_ui(): hr_sampler_name = gr.Dropdown(label='Hires sampling method', elem_id="hr_sampler", choices=["Use same sampler"] + sd_samplers.visible_sampler_names(), value="Use same sampler") hr_scheduler = gr.Dropdown(label='Hires schedule type', elem_id="hr_scheduler", choices=["Use same scheduler"] + [x.label for x in sd_schedulers.schedulers], value="Use same scheduler") - with FormRow(elem_id="txt2img_hires_fix_row4", variant="compact") as hr_prompts_container: + with FormRow(elem_id="txt2img_hires_fix_row4", variant="compact", visible=shared.opts.hires_fix_show_prompts) as hr_prompts_container: with gr.Column(scale=80): with gr.Row(): hr_prompt = gr.Textbox(label="Hires prompt", elem_id="hires_prompt", show_label=False, lines=3, placeholder="Prompt for hires fix pass.\nLeave empty to use the same prompt as in first pass.", elem_classes=["prompt"])