Skip to content

Commit 3bd2c68

Browse files
authored
Add exponential scheduler for DPM-Solver++(2M) SDE
Better quality results than Karras. Related discussion: https://gist.github.com/crowsonkb/3ed16fba35c73ece7cf4b9a2095f2b78
1 parent 71efc5b commit 3bd2c68

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

modules/sd_samplers_kdiffusion.py

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
('DPM++ 2M Karras', 'sample_dpmpp_2m', ['k_dpmpp_2m_ka'], {'scheduler': 'karras'}),
3131
('DPM++ SDE Karras', 'sample_dpmpp_sde', ['k_dpmpp_sde_ka'], {'scheduler': 'karras', "second_order": True, "brownian_noise": True}),
3232
('DPM++ 2M SDE Karras', 'sample_dpmpp_2m_sde', ['k_dpmpp_2m_sde_ka'], {'scheduler': 'karras', "brownian_noise": True}),
33+
('DPM++ 2M SDE Exponential', 'sample_dpmpp_2m_sde', ['k_dpmpp_2m_sde_exp'], {'scheduler': 'exponential', "brownian_noise": True}),
3334
('Restart', sd_samplers_extra.restart_sampler, ['restart'], {'scheduler': 'karras'}),
3435
]
3536

@@ -375,6 +376,9 @@ def get_sigmas(self, p, steps):
375376
sigma_min, sigma_max = (0.1, 10) if opts.use_old_karras_scheduler_sigmas else (self.model_wrap.sigmas[0].item(), self.model_wrap.sigmas[-1].item())
376377

377378
sigmas = k_diffusion.sampling.get_sigmas_karras(n=steps, sigma_min=sigma_min, sigma_max=sigma_max, device=shared.device)
379+
elif self.config is not None and self.config.options.get('scheduler', None) == 'exponential':
380+
m_sigma_min, m_sigma_max = (self.model_wrap.sigmas[0].item(), self.model_wrap.sigmas[-1].item())
381+
sigmas = k_diffusion.sampling.get_sigmas_exponential(n=steps, sigma_min=m_sigma_min, sigma_max=m_sigma_max, device=shared.device)
378382
else:
379383
sigmas = self.model_wrap.get_sigmas(steps)
380384

0 commit comments

Comments
 (0)