From 771ea212de13711b494b082d8e94e79b17ac9d08 Mon Sep 17 00:00:00 2001 From: pieresimakp <69743585+pieresimakp@users.noreply.github.com> Date: Fri, 24 Mar 2023 12:41:17 +0800 Subject: [PATCH 1/2] added button to grab the width and height from the loaded image in img2img --- javascript/hints.js | 1 + modules/ui.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/javascript/hints.js b/javascript/hints.js index 7f4101b2..5bbc27a5 100644 --- a/javascript/hints.js +++ b/javascript/hints.js @@ -9,6 +9,7 @@ titles = { "UniPC": "Unified Predictor-Corrector Framework for Fast Sampling of Diffusion Models", "DPM adaptive": "Ignores step count - uses a number of steps determined by the CFG and resolution", + "\u{1F4D0}": "Auto detect size from img2img", "Batch count": "How many batches of images to create (has no impact on generation performance or VRAM usage)", "Batch size": "How many image to create in a single batch (increases generation performance at cost of higher VRAM usage)", "CFG Scale": "Classifier Free Guidance Scale - how strongly the image should conform to prompt - lower values produce more creative results", diff --git a/modules/ui.py b/modules/ui.py index 7e603332..6c623002 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -92,7 +92,7 @@ apply_style_symbol = '\U0001f4cb' # 📋 clear_prompt_symbol = '\U0001F5D1' # 🗑️ extra_networks_symbol = '\U0001F3B4' # 🎴 switch_values_symbol = '\U000021C5' # ⇅ - +detect_image_size_symbol = '\U0001F4D0' # 📐 def plaintext_to_html(text): return ui_common.plaintext_to_html(text) @@ -756,8 +756,10 @@ def create_ui(): with gr.Column(elem_id="img2img_column_size", scale=4): width = gr.Slider(minimum=64, maximum=2048, step=8, label="Width", value=512, elem_id="img2img_width") height = gr.Slider(minimum=64, maximum=2048, step=8, label="Height", value=512, elem_id="img2img_height") - + + detect_image_size_btn = ToolButton(value=detect_image_size_symbol, elem_id="img2img_detect_image_size_btn") res_switch_btn = ToolButton(value=switch_values_symbol, elem_id="img2img_res_switch_btn") + if opts.dimensions_and_batch_together: with gr.Column(elem_id="img2img_column_batch"): batch_count = gr.Slider(minimum=1, step=1, label='Batch count', value=1, elem_id="img2img_batch_count") @@ -904,6 +906,7 @@ def create_ui(): img2img_prompt.submit(**img2img_args) submit.click(**img2img_args) + detect_image_size_btn.click(lambda i, w, h : i.size if i is not None else (w, h), inputs=[init_img, width, height], outputs=[width, height]) res_switch_btn.click(lambda w, h: (h, w), inputs=[width, height], outputs=[width, height]) img2img_interrogate.click( From fb72066ef6a2fed799468517932a76a39789cca6 Mon Sep 17 00:00:00 2001 From: pieresimakp <69743585+pieresimakp@users.noreply.github.com> Date: Sat, 25 Mar 2023 23:03:22 +0800 Subject: [PATCH 2/2] fixed button position --- modules/ui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ui.py b/modules/ui.py index 9b6e3241..464e4d8c 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -758,8 +758,8 @@ def create_ui(): width = gr.Slider(minimum=64, maximum=2048, step=8, label="Width", value=512, elem_id="img2img_width") height = gr.Slider(minimum=64, maximum=2048, step=8, label="Height", value=512, elem_id="img2img_height") - detect_image_size_btn = ToolButton(value=detect_image_size_symbol, elem_id="img2img_detect_image_size_btn") with gr.Column(elem_id="img2img_dimensions_row", scale=1, elem_classes="dimensions-tools"): + detect_image_size_btn = ToolButton(value=detect_image_size_symbol, elem_id="img2img_detect_image_size_btn") res_switch_btn = ToolButton(value=switch_values_symbol, elem_id="img2img_res_switch_btn") if opts.dimensions_and_batch_together: