This commit is contained in:
Haoming 2026-04-29 17:34:06 +08:00
parent 4037bd6fb6
commit a0233138a3
2 changed files with 20 additions and 7 deletions

View File

@ -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"),
},
)
)

View File

@ -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]