mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-07-21 21:01:24 +08:00
presets
This commit is contained in:
parent
3341f41adc
commit
0c26d5cd9c
@ -2,6 +2,7 @@ import gradio as gr
|
||||
|
||||
from modules import scripts, sd_samplers, sd_schedulers
|
||||
from modules.infotext_utils import PasteField
|
||||
from modules.ui import no_config
|
||||
from modules.ui_components import FormRow
|
||||
|
||||
|
||||
@ -31,6 +32,7 @@ class ScriptSampler(scripts.ScriptBuiltinUI):
|
||||
PasteField(self.scheduler, sd_samplers.get_scheduler_from_infotext, api="scheduler"),
|
||||
]
|
||||
|
||||
no_config(self.sampler_name, self.scheduler, self.steps)
|
||||
return self.steps, self.sampler_name, self.scheduler
|
||||
|
||||
def setup(self, p, steps, sampler_name, scheduler):
|
||||
|
||||
@ -57,6 +57,11 @@ def gr_show(visible=True):
|
||||
return {"visible": visible, "__type__": "update"}
|
||||
|
||||
|
||||
def no_config(*comps: gr.components.Component):
|
||||
for comp in comps:
|
||||
comp.do_not_save_to_config = True
|
||||
|
||||
|
||||
# Using constants for these since the variation selector isn't visible.
|
||||
# Important that they exactly match script.js for tooltip to work.
|
||||
random_symbol = "\U0001f3b2\ufe0f" # 🎲️
|
||||
@ -442,6 +447,9 @@ def create_ui():
|
||||
|
||||
steps = scripts.scripts_txt2img.script("Sampler").steps
|
||||
|
||||
no_config(width, height, cfg_scale, distilled_cfg_scale, batch_size)
|
||||
no_config(hr_second_pass_steps, hr_cfg, hr_distilled_cfg)
|
||||
|
||||
toprow.ui_styles.dropdown.change(fn=wrap_queued_call(update_token_counter), inputs=[toprow.prompt, steps, toprow.ui_styles.dropdown], outputs=[toprow.token_counter])
|
||||
toprow.ui_styles.dropdown.change(fn=wrap_queued_call(update_negative_prompt_token_counter), inputs=[toprow.negative_prompt, steps, toprow.ui_styles.dropdown], outputs=[toprow.negative_token_counter])
|
||||
toprow.token_button.click(fn=wrap_queued_call(update_token_counter), inputs=[toprow.prompt, steps, toprow.ui_styles.dropdown], outputs=[toprow.token_counter])
|
||||
@ -758,14 +766,24 @@ def create_ui():
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
steps = scripts.scripts_img2img.script("Sampler").steps
|
||||
|
||||
toprow.ui_styles.dropdown.change(fn=wrap_queued_call(update_token_counter), inputs=[toprow.prompt, steps, toprow.ui_styles.dropdown], outputs=[toprow.token_counter])
|
||||
toprow.ui_styles.dropdown.change(fn=wrap_queued_call(update_negative_prompt_token_counter), inputs=[toprow.negative_prompt, steps, toprow.ui_styles.dropdown], outputs=[toprow.negative_token_counter])
|
||||
toprow.token_button.click(fn=update_token_counter, inputs=[toprow.prompt, steps, toprow.ui_styles.dropdown], outputs=[toprow.token_counter])
|
||||
toprow.negative_token_button.click(fn=wrap_queued_call(update_negative_prompt_token_counter), inputs=[toprow.negative_prompt, steps, toprow.ui_styles.dropdown], outputs=[toprow.negative_token_counter])
|
||||
|
||||
img2img_paste_fields = [(toprow.prompt, "Prompt"), (toprow.negative_prompt, "Negative prompt"), (cfg_scale, "CFG scale"), (distilled_cfg_scale, "Distilled CFG Scale"), (image_cfg_scale, "Image CFG scale"), (width, "Size-1"), (height, "Size-2"), (batch_size, "Batch size"), (toprow.ui_styles.dropdown, lambda d: d["Styles array"] if isinstance(d.get("Styles array"), list) else gr.skip()), (denoising_strength, "Denoising strength"), (mask_blur, "Mask blur"), (inpainting_mask_invert, "Mask mode"), (inpainting_fill, "Masked content"), (inpaint_full_res, "Inpaint area"), (inpaint_full_res_padding, "Masked area padding"), *scripts.scripts_img2img.infotext_fields]
|
||||
img2img_paste_fields = [
|
||||
(toprow.prompt, "Prompt"),
|
||||
(toprow.negative_prompt, "Negative prompt"),
|
||||
(cfg_scale, "CFG scale"),
|
||||
(distilled_cfg_scale, "Distilled CFG Scale"),
|
||||
(image_cfg_scale, "Image CFG scale"),
|
||||
(width, "Size-1"),
|
||||
(height, "Size-2"),
|
||||
(batch_size, "Batch size"),
|
||||
(toprow.ui_styles.dropdown, lambda d: d["Styles array"] if isinstance(d.get("Styles array"), list) else gr.skip()),
|
||||
(denoising_strength, "Denoising strength"),
|
||||
(mask_blur, "Mask blur"),
|
||||
(inpainting_mask_invert, "Mask mode"),
|
||||
(inpainting_fill, "Masked content"),
|
||||
(inpaint_full_res, "Inpaint area"),
|
||||
(inpaint_full_res_padding, "Masked area padding"),
|
||||
*scripts.scripts_img2img.infotext_fields,
|
||||
]
|
||||
parameters_copypaste.add_paste_fields("img2img", init_img.background, img2img_paste_fields, override_settings)
|
||||
parameters_copypaste.add_paste_fields("inpaint", init_img_with_mask.background, img2img_paste_fields, override_settings)
|
||||
parameters_copypaste.register_paste_params_button(
|
||||
@ -777,6 +795,15 @@ def create_ui():
|
||||
)
|
||||
)
|
||||
|
||||
steps = scripts.scripts_img2img.script("Sampler").steps
|
||||
|
||||
no_config(width, height, cfg_scale, distilled_cfg_scale, batch_size)
|
||||
|
||||
toprow.ui_styles.dropdown.change(fn=wrap_queued_call(update_token_counter), inputs=[toprow.prompt, steps, toprow.ui_styles.dropdown], outputs=[toprow.token_counter])
|
||||
toprow.ui_styles.dropdown.change(fn=wrap_queued_call(update_negative_prompt_token_counter), inputs=[toprow.negative_prompt, steps, toprow.ui_styles.dropdown], outputs=[toprow.negative_token_counter])
|
||||
toprow.token_button.click(fn=update_token_counter, inputs=[toprow.prompt, steps, toprow.ui_styles.dropdown], outputs=[toprow.token_counter])
|
||||
toprow.negative_token_button.click(fn=wrap_queued_call(update_negative_prompt_token_counter), inputs=[toprow.negative_prompt, steps, toprow.ui_styles.dropdown], outputs=[toprow.negative_token_counter])
|
||||
|
||||
extra_networks_ui_img2img = ui_extra_networks.create_ui(img2img_interface, [img2img_generation_tab], "img2img")
|
||||
ui_extra_networks.setup_ui(extra_networks_ui_img2img, output_panel.gallery)
|
||||
|
||||
|
||||
@ -127,12 +127,12 @@ def register(options_templates: dict):
|
||||
(f"ui_{name}", name.upper(), "presets"),
|
||||
{
|
||||
f"{name}_t2i_ss1": OptionRow(),
|
||||
f"{name}_t2i_sampler": OptionInfo(sampler, "txt2img sampler", Dropdown, lambda: {"choices": [x.name for x in list_samplers()]}),
|
||||
f"{name}_t2i_scheduler": OptionInfo(scheduler, "txt2img scheduler", Dropdown, lambda: {"choices": list_schedulers()}),
|
||||
f"{name}_t2i_sampler": OptionInfo(sampler, "txt2img Sampler", Dropdown, lambda: {"choices": [x.name for x in list_samplers()]}),
|
||||
f"{name}_t2i_scheduler": OptionInfo(scheduler, "txt2img Scheduler", Dropdown, lambda: {"choices": list_schedulers()}),
|
||||
f"{name}_t2i_ss0": OptionRow(),
|
||||
f"{name}_i2i_ss1": OptionRow(),
|
||||
f"{name}_i2i_sampler": OptionInfo(sampler, "img2img sampler", Dropdown, lambda: {"choices": [x.name for x in list_samplers()]}),
|
||||
f"{name}_i2i_scheduler": OptionInfo(scheduler, "img2img scheduler", Dropdown, lambda: {"choices": list_schedulers()}),
|
||||
f"{name}_i2i_sampler": OptionInfo(sampler, "img2img Sampler", Dropdown, lambda: {"choices": [x.name for x in list_samplers()]}),
|
||||
f"{name}_i2i_scheduler": OptionInfo(scheduler, "img2img Scheduler", Dropdown, lambda: {"choices": list_schedulers()}),
|
||||
f"{name}_i2i_ss0": OptionRow(),
|
||||
},
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user