Skip to content

Commit

Permalink
restore use of Settings for hiresfix options (AUTOMATIC1111#1706)
Browse files Browse the repository at this point in the history
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.

AUTOMATIC1111#1247
  • Loading branch information
DenOfEquity authored Sep 8, 2024
1 parent 44eb4ea commit 7d5b31b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions modules/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <span class='resolution'>{p.width}x{p.height}</span> to <span class='resolution'>{p.hr_resize_x or p.hr_upscale_to_x}x{p.hr_resize_y or p.hr_upscale_to_y}</span>"
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 <span class='resolution'>{p.width}x{p.height}</span> to <span class='resolution'>{new_width}x{new_height}</span>"


def resize_from_to_html(width, height, scale_by):
Expand Down Expand Up @@ -332,15 +338,15 @@ 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")

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"])
Expand Down

0 comments on commit 7d5b31b

Please sign in to comment.