Unverified Commit 01cc07b8 authored by AUTOMATIC1111's avatar AUTOMATIC1111 Committed by GitHub
Browse files

Merge pull request #6437 from Mitchell1711/show-target-resolution

Show upscaled resolution on hires fix
parents c4a221c4 f94cfc56
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -255,6 +255,12 @@ def add_style(name: str, prompt: str, negative_prompt: str):

    return [gr.Dropdown.update(visible=True, choices=list(shared.prompt_styles.styles)) for _ in range(4)]

def calc_resolution_hires(x, y, scale):
    #final res can only be a multiple of 8
    scaled_x = int(x * scale // 8) * 8
    scaled_y = int(y * scale // 8) * 8
    
    return str(scaled_x)+"x"+str(scaled_y)

def apply_styles(prompt, prompt_neg, style1_name, style2_name):
    prompt = shared.prompt_styles.apply_styles_to_prompt(prompt, [style1_name, style2_name])
@@ -719,6 +725,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"):        
                                hr_final_resolution = gr.Textbox(value=calc_resolution_hires(width.value, height.value, hr_scale.value), 
                                    elem_id="txtimg_hr_finalres", 
                                    label="Upscaled resolution",
                                    interactive=False)
                                hr_scale.change(fn=calc_resolution_hires, inputs=[width, height, hr_scale], outputs=hr_final_resolution, show_progress=False)
                                width.change(fn=calc_resolution_hires, inputs=[width, height, hr_scale], outputs=hr_final_resolution, show_progress=False)
                                height.change(fn=calc_resolution_hires, inputs=[width, height, hr_scale], outputs=hr_final_resolution, show_progress=False)

                    elif category == "batch":
                        if not opts.dimensions_and_batch_together:
                            with FormRow(elem_id="txt2img_column_batch"):