From 31306ce6721e6f1ae323da64767da91897b3a1c2 Mon Sep 17 00:00:00 2001 From: AUTOMATIC1111 <16777216c@gmail.com> Date: Wed, 20 Mar 2024 10:29:52 +0300 Subject: [PATCH] change the behavior of discard_next_to_last_sigma for sgm_uniform to match other schedulers --- modules/sd_samplers_kdiffusion.py | 4 ---- modules/sd_schedulers.py | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/sd_samplers_kdiffusion.py b/modules/sd_samplers_kdiffusion.py index 04b2f7f0c..d053e48b1 100644 --- a/modules/sd_samplers_kdiffusion.py +++ b/modules/sd_samplers_kdiffusion.py @@ -113,10 +113,6 @@ class KDiffusionSampler(sd_samplers_common.Sampler): if scheduler.need_inner_model: sigmas_kwargs['inner_model'] = self.model_wrap - if scheduler.name == "sgm_uniform": # XXX check this - # Ensure the "step" will be target step + 1 - steps += 1 if not discard_next_to_last_sigma else 0 - sigmas = scheduler.function(n=steps, **sigmas_kwargs, device=shared.device) if discard_next_to_last_sigma: diff --git a/modules/sd_schedulers.py b/modules/sd_schedulers.py index 2a7ab0924..75eb3ac03 100644 --- a/modules/sd_schedulers.py +++ b/modules/sd_schedulers.py @@ -25,7 +25,7 @@ def sgm_uniform(n, sigma_min, sigma_max, inner_model, device): end = inner_model.sigma_to_t(torch.tensor(sigma_min)) sigs = [ inner_model.t_to_sigma(ts) - for ts in torch.linspace(start, end, n)[:-1] + for ts in torch.linspace(start, end, n + 1)[:-1] ] sigs += [0.0] return torch.FloatTensor(sigs).to(device)