mirror of
https://github.com/sd-webui/stable-diffusion-webui.git
synced 2024-12-15 07:12:58 +03:00
Add dimensions info (aspect ratio and pixel count)
This commit is contained in:
parent
7fb25b25a4
commit
4ec2d328db
@ -38,6 +38,7 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x, txt2img_defaul
|
|||||||
txt2img_batch_size = gr.Slider(minimum=1, maximum=8, step=1,
|
txt2img_batch_size = gr.Slider(minimum=1, maximum=8, step=1,
|
||||||
label='Batch size (how many images are in a batch; memory-hungry)',
|
label='Batch size (how many images are in a batch; memory-hungry)',
|
||||||
value=txt2img_defaults['batch_size'])
|
value=txt2img_defaults['batch_size'])
|
||||||
|
txt2img_dimensions_info_text_box = gr.Textbox(label="Aspect ratio (4:3 = 1.333 | 16:9 = 1.777 | 21:9 = 2.333)")
|
||||||
with gr.Column():
|
with gr.Column():
|
||||||
output_txt2img_gallery = gr.Gallery(label="Images", elem_id="txt2img_gallery_output").style(grid=[4, 4])
|
output_txt2img_gallery = gr.Gallery(label="Images", elem_id="txt2img_gallery_output").style(grid=[4, 4])
|
||||||
|
|
||||||
@ -113,6 +114,8 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x, txt2img_defaul
|
|||||||
txt2img_height, txt2img_width, txt2img_embeddings, txt2img_variant_amount, txt2img_variant_seed],
|
txt2img_height, txt2img_width, txt2img_embeddings, txt2img_variant_amount, txt2img_variant_seed],
|
||||||
[output_txt2img_gallery, output_txt2img_seed, output_txt2img_params, output_txt2img_stats]
|
[output_txt2img_gallery, output_txt2img_seed, output_txt2img_params, output_txt2img_stats]
|
||||||
)
|
)
|
||||||
|
txt2img_width.change(fn=uifn.update_dimensions_info, inputs=[txt2img_width, txt2img_height], outputs=txt2img_dimensions_info_text_box)
|
||||||
|
txt2img_height.change(fn=uifn.update_dimensions_info, inputs=[txt2img_width, txt2img_height], outputs=txt2img_dimensions_info_text_box)
|
||||||
|
|
||||||
with gr.TabItem("Stable Diffusion Image-to-Image Unified", id="img2img_tab"):
|
with gr.TabItem("Stable Diffusion Image-to-Image Unified", id="img2img_tab"):
|
||||||
with gr.Row(elem_id="prompt_row"):
|
with gr.Row(elem_id="prompt_row"):
|
||||||
@ -202,6 +205,7 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x, txt2img_defaul
|
|||||||
img2img_batch_size = gr.Slider(minimum=1, maximum=8, step=1,
|
img2img_batch_size = gr.Slider(minimum=1, maximum=8, step=1,
|
||||||
label='Batch size (how many images are in a batch; memory-hungry)',
|
label='Batch size (how many images are in a batch; memory-hungry)',
|
||||||
value=img2img_defaults['batch_size'])
|
value=img2img_defaults['batch_size'])
|
||||||
|
img2img_dimensions_info_text_box = gr.Textbox(label="Aspect ratio (4:3 = 1.333 | 16:9 = 1.777 | 21:9 = 2.333)")
|
||||||
with gr.Column():
|
with gr.Column():
|
||||||
img2img_steps = gr.Slider(minimum=1, maximum=250, step=1, label="Sampling Steps",
|
img2img_steps = gr.Slider(minimum=1, maximum=250, step=1, label="Sampling Steps",
|
||||||
value=img2img_defaults['ddim_steps'])
|
value=img2img_defaults['ddim_steps'])
|
||||||
@ -287,6 +291,9 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x, txt2img_defaul
|
|||||||
|
|
||||||
img2img_painterro_btn.click(None, [img2img_image_editor], [img2img_image_editor, img2img_image_mask], _js=js_painterro_launch('img2img_editor'))
|
img2img_painterro_btn.click(None, [img2img_image_editor], [img2img_image_editor, img2img_image_mask], _js=js_painterro_launch('img2img_editor'))
|
||||||
|
|
||||||
|
img2img_width.change(fn=uifn.update_dimensions_info, inputs=[img2img_width, img2img_height], outputs=img2img_dimensions_info_text_box)
|
||||||
|
img2img_height.change(fn=uifn.update_dimensions_info, inputs=[img2img_width, img2img_height], outputs=img2img_dimensions_info_text_box)
|
||||||
|
|
||||||
if GFPGAN is not None:
|
if GFPGAN is not None:
|
||||||
gfpgan_defaults = {
|
gfpgan_defaults = {
|
||||||
'strength': 100,
|
'strength': 100,
|
||||||
|
@ -106,3 +106,7 @@ def resize_image(resize_mode, im, width, height):
|
|||||||
res.paste(resized.resize((fill_width, height), box=(resized.width, 0, resized.width, height)), box=(fill_width + src_w, 0))
|
res.paste(resized.resize((fill_width, height), box=(resized.width, 0, resized.width, height)), box=(fill_width + src_w, 0))
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def update_dimensions_info(width, height):
|
||||||
|
pixel_count_formated = "{:,.0f}".format(width * height)
|
||||||
|
return f"Aspect ratio: {round(width / height, 5)}\nTotal pixel count: {pixel_count_formated}"
|
||||||
|
Loading…
Reference in New Issue
Block a user