Skip to content

Commit d1142e4

Browse files
AUTOMATIC1111ruchej
authored andcommitted
add proper infotext support for AUTOMATIC1111#15607
fix settings override not working for NGMI, s_churn, etc...
1 parent 32ce677 commit d1142e4

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

modules/processing.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,6 @@ def __post_init__(self):
238238
self.styles = []
239239

240240
self.sampler_noise_scheduler_override = None
241-
self.s_min_uncond = self.s_min_uncond if self.s_min_uncond is not None else opts.s_min_uncond
242-
self.s_churn = self.s_churn if self.s_churn is not None else opts.s_churn
243-
self.s_tmin = self.s_tmin if self.s_tmin is not None else opts.s_tmin
244-
self.s_tmax = (self.s_tmax if self.s_tmax is not None else opts.s_tmax) or float('inf')
245-
self.s_noise = self.s_noise if self.s_noise is not None else opts.s_noise
246241

247242
self.extra_generation_params = self.extra_generation_params or {}
248243
self.override_settings = self.override_settings or {}
@@ -259,6 +254,13 @@ def __post_init__(self):
259254
self.cached_uc = StableDiffusionProcessing.cached_uc
260255
self.cached_c = StableDiffusionProcessing.cached_c
261256

257+
def fill_fields_from_opts(self):
258+
self.s_min_uncond = self.s_min_uncond if self.s_min_uncond is not None else opts.s_min_uncond
259+
self.s_churn = self.s_churn if self.s_churn is not None else opts.s_churn
260+
self.s_tmin = self.s_tmin if self.s_tmin is not None else opts.s_tmin
261+
self.s_tmax = (self.s_tmax if self.s_tmax is not None else opts.s_tmax) or float('inf')
262+
self.s_noise = self.s_noise if self.s_noise is not None else opts.s_noise
263+
262264
@property
263265
def sd_model(self):
264266
return shared.sd_model
@@ -794,7 +796,6 @@ def create_infotext(p, all_prompts, all_seeds, all_subseeds, comments=None, iter
794796
"Token merging ratio hr": None if not enable_hr or token_merging_ratio_hr == 0 else token_merging_ratio_hr,
795797
"Init image hash": getattr(p, 'init_img_hash', None),
796798
"RNG": opts.randn_source if opts.randn_source != "GPU" else None,
797-
"NGMS": None if p.s_min_uncond == 0 else p.s_min_uncond,
798799
"Tiling": "True" if p.tiling else None,
799800
**p.extra_generation_params,
800801
"Version": program_version() if opts.add_version_to_infotext else None,
@@ -890,6 +891,7 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
890891
modules.sd_hijack.model_hijack.apply_circular(p.tiling)
891892
modules.sd_hijack.model_hijack.clear_comments()
892893

894+
p.fill_fields_from_opts()
893895
p.setup_prompts()
894896

895897
if isinstance(seed, list):

modules/sd_samplers_cfg_denoiser.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,14 @@ def apply_blend(current_latent):
214214

215215
if shared.opts.skip_early_cond != 0. and self.step / self.total_steps <= shared.opts.skip_early_cond:
216216
skip_uncond = True
217-
x_in = x_in[:-batch_size]
218-
sigma_in = sigma_in[:-batch_size]
219-
220-
# alternating uncond allows for higher thresholds without the quality loss normally expected from raising it
221-
if (self.step % 2 or shared.opts.s_min_uncond_all) and s_min_uncond > 0 and sigma[0] < s_min_uncond and not is_edit_model:
217+
self.p.extra_generation_params["Skip Early CFG"] = shared.opts.skip_early_cond
218+
elif (self.step % 2 or shared.opts.s_min_uncond_all) and s_min_uncond > 0 and sigma[0] < s_min_uncond and not is_edit_model:
222219
skip_uncond = True
220+
self.p.extra_generation_params["NGMS"] = s_min_uncond
221+
if shared.opts.s_min_uncond_all:
222+
self.p.extra_generation_params["NGMS all steps"] = shared.opts.s_min_uncond_all
223+
224+
if skip_uncond:
223225
x_in = x_in[:-batch_size]
224226
sigma_in = sigma_in[:-batch_size]
225227

modules/shared_options.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@
209209

210210
options_templates.update(options_section(('optimizations', "Optimizations", "sd"), {
211211
"cross_attention_optimization": OptionInfo("Automatic", "Cross attention optimization", gr.Dropdown, lambda: {"choices": shared_items.cross_attention_optimizations()}),
212-
"s_min_uncond": OptionInfo(0.0, "Negative Guidance minimum sigma", gr.Slider, {"minimum": 0.0, "maximum": 15.0, "step": 0.01}).link("PR", "https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9177").info("skip negative prompt for some steps when the image is almost ready; 0=disable, higher=faster"),
213-
"s_min_uncond_all": OptionInfo(False, "NGMS: Skip every step").info("makes Negative Guidance minimum sigma skip negative guidance on every step instead of only half"),
212+
"s_min_uncond": OptionInfo(0.0, "Negative Guidance minimum sigma", gr.Slider, {"minimum": 0.0, "maximum": 15.0, "step": 0.01}, infotext='NGMS').link("PR", "https://github.com/AUTOMATIC1111/stablediffusion-webui/pull/9177").info("skip negative prompt for some steps when the image is almost ready; 0=disable, higher=faster"),
213+
"s_min_uncond_all": OptionInfo(False, "Negative Guidance minimum sigma all steps", infotext='NGMS all steps').info("By default, NGMS above skips every other step; this makes it skip all steps"),
214214
"token_merging_ratio": OptionInfo(0.0, "Token merging ratio", gr.Slider, {"minimum": 0.0, "maximum": 0.9, "step": 0.1}, infotext='Token merging ratio').link("PR", "https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9256").info("0=disable, higher=faster"),
215215
"token_merging_ratio_img2img": OptionInfo(0.0, "Token merging ratio for img2img", gr.Slider, {"minimum": 0.0, "maximum": 0.9, "step": 0.1}).info("only applies if non-zero and overrides above"),
216216
"token_merging_ratio_hr": OptionInfo(0.0, "Token merging ratio for high-res pass", gr.Slider, {"minimum": 0.0, "maximum": 0.9, "step": 0.1}, infotext='Token merging ratio hr').info("only applies if non-zero and overrides above"),
@@ -382,7 +382,7 @@
382382
'uni_pc_order': OptionInfo(3, "UniPC order", gr.Slider, {"minimum": 1, "maximum": 50, "step": 1}, infotext='UniPC order').info("must be < sampling steps"),
383383
'uni_pc_lower_order_final': OptionInfo(True, "UniPC lower order final", infotext='UniPC lower order final'),
384384
'sd_noise_schedule': OptionInfo("Default", "Noise schedule for sampling", gr.Radio, {"choices": ["Default", "Zero Terminal SNR"]}, infotext="Noise Schedule").info("for use with zero terminal SNR trained models"),
385-
'skip_early_cond': OptionInfo(0, "Skip CFG during early sampling", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}, infotext="Skip Early CFG").info("CFG will be disabled (set to 1) on early steps, can both improve sample diversity/quality and speed up sampling"),
385+
'skip_early_cond': OptionInfo(0.0, "Ignore negative prompt during early sampling", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}, infotext="Skip Early CFG").info("disables CFG on a proportion of steps at the beginning of generation; 0=skip none; 1=skip all; can both improve sample diversity/quality and speed up sampling"),
386386
}))
387387

388388
options_templates.update(options_section(('postprocessing', "Postprocessing", "postprocessing"), {

0 commit comments

Comments
 (0)