Added UI elements
Added a new row to hires fix that shows the new resolution after scaling
This commit is contained in:
parent
874b975bf8
commit
3992ecbe6e
|
@ -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 "<p style='margin: -1em 0em 0.7em 1.35em'>Upscaled Resolution: "+str(scaled_x)+"x"+str(scaled_y)+"</p>"
|
||||
|
||||
def apply_styles(prompt, prompt_neg, style1_name, style2_name):
|
||||
prompt = shared.prompt_styles.apply_styles_to_prompt(prompt, [style1_name, style2_name])
|
||||
|
@ -718,6 +724,12 @@ def create_ui():
|
|||
hr_scale = gr.Slider(minimum=1.0, maximum=4.0, step=0.05, label="Upscale by", value=2.0, elem_id="txt2img_hr_scale")
|
||||
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.HTML(value=calc_resolution_hires(width.value, height.value, hr_scale.value), elem_id="txtimg_hr_finalres")
|
||||
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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user