From a0233138a3596ccee695221be23ba75b4f8c8f90 Mon Sep 17 00:00:00 2001 From: Haoming Date: Wed, 29 Apr 2026 17:34:06 +0800 Subject: [PATCH] settings --- modules/shared_options.py | 14 ++++++++++++-- modules/txt2img.py | 13 ++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/modules/shared_options.py b/modules/shared_options.py index d1510333..3597a179 100644 --- a/modules/shared_options.py +++ b/modules/shared_options.py @@ -274,6 +274,18 @@ to create the resulting image after the sampling is finished. For img2img, VAE i ) ) +options_templates.update( + options_section( + ("txt2img", "txt2img", "sd"), + { + "txt2img_upscale_single_batch": OptionInfo(True, "When using the [✨] button, lock the Batch Count and Batch Size to 1 regardless of the UI values"), + "txt2img_upscale_same_seed": OptionInfo(True, "When using the [✨] button, pass the Seed of the input image instead of the UI value"), + "hires_button_gallery_insert": OptionInfo(False, "When using the [✨] button, insert the upscaled image to the gallery").info("otherwise replace the selected image in the gallery"), + "hires_insert_index": OptionInfo(True, "When the above option is enabled, automatically select the upscaled image").info("otherwise select the original image"), + }, + ) +) + options_templates.update( options_section( ("img2img", "img2img", "sd"), @@ -423,8 +435,6 @@ options_templates.update( "sd_webui_modal_lightbox_icon_opacity": OptionInfo(1.0, "[Lightbox]: control icon unfocused opacity", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.05}, onchange=shared.reload_gradio_theme).info("for mouse only").needs_reload_ui(), "sd_webui_modal_lightbox_toolbar_opacity": OptionInfo(0.9, "[Lightbox]: tool bar opacity", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.05}, onchange=shared.reload_gradio_theme).info("for mouse only").needs_reload_ui(), "open_dir_button_choice": OptionInfo("Subdirectory", "What directory the [📂] button opens", gr.Radio, {"choices": ("Output Root", "Subdirectory", "Subdirectory (even temp dir)")}), - "hires_button_gallery_insert": OptionInfo(False, "When using the [✨] button, insert the upscaled image to the gallery").info("otherwise replace the selected image in the gallery"), - "hires_insert_index": OptionInfo(True, "When the above option is enabled, automatically select the upscaled image").info("otherwise select the original image"), }, ) ) diff --git a/modules/txt2img.py b/modules/txt2img.py index ea1e50b8..834c1eb1 100644 --- a/modules/txt2img.py +++ b/modules/txt2img.py @@ -78,17 +78,20 @@ def txt2img_upscale_function(id_task: str, request: gr.Request, gallery, gallery return gallery, generation_info, "Unable to upscale grid or control images.", "" p = txt2img_create_processing(id_task, request, *args, force_enable_hr=True) - p.batch_size = 1 - p.n_iter = 1 + if opts.txt2img_upscale_single_batch: + p.batch_size = 1 + p.n_iter = 1 + # txt2img_upscale attribute that signifies this is called by txt2img_upscale p.txt2img_upscale = True image_info = gallery[gallery_index] p.firstpass_image = infotext_utils.image_from_url_text(image_info) - parameters = parse_generation_parameters(geninfo.get("infotexts")[gallery_index], []) - p.seed = parameters.get("Seed", -1) - p.subseed = parameters.get("Variation seed", -1) + if opts.txt2img_upscale_same_seed: + parameters = parse_generation_parameters(geninfo.get("infotexts")[gallery_index], []) + p.seed = parameters.get("Seed", -1) + p.subseed = parameters.get("Variation seed", -1) # update processing width/height based on actual dimensions of source image p.width = gallery[gallery_index][0].size[0]