aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2023-05-27 19:53:09 +0300
committerAUTOMATIC <16777216c@gmail.com>2023-05-27 19:53:09 +0300
commite8e7fe11e903115a706187f8301df2e06fa018f8 (patch)
tree3f83d3c14d60b94f440c75a60a94a81ca1c3a5e6 /modules
parent654234ec56f92c5f480b611147453e669a7777bc (diff)
updates for the noise schedule settings
Diffstat (limited to 'modules')
-rw-r--r--modules/generation_parameters_copypaste.py24
-rw-r--r--modules/sd_samplers_kdiffusion.py30
-rw-r--r--modules/shared.py8
3 files changed, 32 insertions, 30 deletions
diff --git a/modules/generation_parameters_copypaste.py b/modules/generation_parameters_copypaste.py
index 1443c5cd..81aef502 100644
--- a/modules/generation_parameters_copypaste.py
+++ b/modules/generation_parameters_copypaste.py
@@ -306,17 +306,17 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model
if "RNG" not in res:
res["RNG"] = "GPU"
- if "KDiff Schedule Type" not in res:
- res["KDiff Schedule Type"] = "Automatic"
+ if "Schedule type" not in res:
+ res["Schedule type"] = "Automatic"
- if "KDiff Schedule max sigma" not in res:
- res["KDiff Schedule max sigma"] = 14.6
+ if "Schedule max sigma" not in res:
+ res["Schedule max sigma"] = 0
- if "KDiff Schedule min sigma" not in res:
- res["KDiff Schedule min sigma"] = 0.3
+ if "Schedule min sigma" not in res:
+ res["Schedule min sigma"] = 0
- if "KDiff Schedule rho" not in res:
- res["KDiff Schedule rho"] = 7.0
+ if "Schedule rho" not in res:
+ res["Schedule rho"] = 0
return res
@@ -330,10 +330,10 @@ infotext_to_setting_name_mapping = [
('Conditional mask weight', 'inpainting_mask_weight'),
('Model hash', 'sd_model_checkpoint'),
('ENSD', 'eta_noise_seed_delta'),
- ('KDiff Schedule Type', 'k_sched_type'),
- ('KDiff Schedule max sigma', 'sigma_max'),
- ('KDiff Schedule min sigma', 'sigma_min'),
- ('KDiff Schedule rho', 'rho'),
+ ('Schedule type', 'k_sched_type'),
+ ('Schedule max sigma', 'sigma_max'),
+ ('Schedule min sigma', 'sigma_min'),
+ ('Schedule rho', 'rho'),
('Noise multiplier', 'initial_noise_multiplier'),
('Eta', 'eta_ancestral'),
('Eta DDIM', 'eta_ddim'),
diff --git a/modules/sd_samplers_kdiffusion.py b/modules/sd_samplers_kdiffusion.py
index 9c9d9f17..e9ba2c61 100644
--- a/modules/sd_samplers_kdiffusion.py
+++ b/modules/sd_samplers_kdiffusion.py
@@ -321,25 +321,27 @@ class KDiffusionSampler:
sigmas = p.sampler_noise_scheduler_override(steps)
elif opts.k_sched_type != "Automatic":
m_sigma_min, m_sigma_max = (self.model_wrap.sigmas[0].item(), self.model_wrap.sigmas[-1].item())
- sigma_min, sigma_max = (0.1, 10)
+ sigma_min, sigma_max = (0.1, 10) if opts.use_old_karras_scheduler_sigmas else (m_sigma_min, m_sigma_max)
sigmas_kwargs = {
- 'sigma_min': sigma_min if opts.use_old_karras_scheduler_sigmas else m_sigma_min,
- 'sigma_max': sigma_max if opts.use_old_karras_scheduler_sigmas else m_sigma_max
+ 'sigma_min': sigma_min,
+ 'sigma_max': sigma_max,
}
sigmas_func = k_diffusion_scheduler[opts.k_sched_type]
- p.extra_generation_params["KDiff Schedule Type"] = opts.k_sched_type
-
- if opts.sigma_min != 0.3:
- # take 0.0 as model default
- sigmas_kwargs['sigma_min'] = opts.sigma_min or m_sigma_min
- p.extra_generation_params["KDiff Schedule min sigma"] = opts.sigma_min
- if opts.sigma_max != 14.6:
- sigmas_kwargs['sigma_max'] = opts.sigma_max or m_sigma_max
- p.extra_generation_params["KDiff Schedule max sigma"] = opts.sigma_max
- if opts.k_sched_type != 'exponential':
+ p.extra_generation_params["Schedule type"] = opts.k_sched_type
+
+ if opts.sigma_min != m_sigma_min and opts.sigma_min != 0:
+ sigmas_kwargs['sigma_min'] = opts.sigma_min
+ p.extra_generation_params["Schedule min sigma"] = opts.sigma_min
+ if opts.sigma_max != m_sigma_max and opts.sigma_max != 0:
+ sigmas_kwargs['sigma_max'] = opts.sigma_max
+ p.extra_generation_params["Schedule max sigma"] = opts.sigma_max
+
+ default_rho = 1. if opts.k_sched_type == "polyexponential" else 7.
+
+ if opts.k_sched_type != 'exponential' and opts.rho != 0 and opts.rho != default_rho:
sigmas_kwargs['rho'] = opts.rho
- p.extra_generation_params["KDiff Schedule rho"] = opts.rho
+ p.extra_generation_params["Schedule rho"] = opts.rho
sigmas = sigmas_func(n=steps, **sigmas_kwargs, device=shared.device)
elif self.config is not None and self.config.options.get('scheduler', None) == 'karras':
diff --git a/modules/shared.py b/modules/shared.py
index 364a5991..daab38dc 100644
--- a/modules/shared.py
+++ b/modules/shared.py
@@ -518,10 +518,10 @@ options_templates.update(options_section(('sampler-params', "Sampler parameters"
's_churn': OptionInfo(0.0, "sigma churn", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}),
's_tmin': OptionInfo(0.0, "sigma tmin", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}),
's_noise': OptionInfo(1.0, "sigma noise", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}),
- 'k_sched_type': OptionInfo("Automatic", "scheduler type", gr.Dropdown, {"choices": ["Automatic", "karras", "exponential", "polyexponential"]}),
- 'sigma_max': OptionInfo(14.6, "sigma max", gr.Number).info("the maximum noise strength for the scheduler. Set to 0 to use the same value which 'xxx karras' samplers use."),
- 'sigma_min': OptionInfo(0.3, "sigma min", gr.Number).info("the minimum noise strength for the scheduler. Set to 0 to use the same value which 'xxx karras' samplers use."),
- 'rho': OptionInfo(7.0, "rho", gr.Number).info("higher will make a more steep noise scheduler (decrease faster). default for karras is 7.0, for polyexponential is 1.0"),
+ 'k_sched_type': OptionInfo("Automatic", "scheduler type", gr.Dropdown, {"choices": ["Automatic", "karras", "exponential", "polyexponential"]}).info("lets you override the noise schedule for k-diffusion samplers; choosing Automatic disables the three parameters below"),
+ 'sigma_min': OptionInfo(0.0, "sigma min", gr.Number).info("0 = default (~0.03); minimum noise strength for k-diffusion noise scheduler"),
+ 'sigma_max': OptionInfo(0.0, "sigma max", gr.Number).info("0 = default (~14.6); maximum noise strength for k-diffusion noise schedule"),
+ 'rho': OptionInfo(0.0, "rho", gr.Number).info("0 = default (7 for karras, 1 for polyexponential); higher values result in a more steep noise schedule (decreases faster)"),
'eta_noise_seed_delta': OptionInfo(0, "Eta noise seed delta", gr.Number, {"precision": 0}).info("ENSD; does not improve anything, just produces different results for ancestral samplers - only useful for reproducing images"),
'always_discard_next_to_last_sigma': OptionInfo(False, "Always discard next-to-last sigma").link("PR", "https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/6044"),
'uni_pc_variant': OptionInfo("bh1", "UniPC variant", gr.Radio, {"choices": ["bh1", "bh2", "vary_coeff"]}),