Add custom karras scheduler

This commit is contained in:
Kohaku-Blueleaf
2023-05-22 21:52:46 +08:00
parent ee65e72931
commit a104879869
7 changed files with 75 additions and 3 deletions

View File

@@ -304,6 +304,12 @@ class KDiffusionSampler:
if p.sampler_noise_scheduler_override:
sigmas = p.sampler_noise_scheduler_override(steps)
elif p.enable_karras:
sigma_max = p.sigma_max
sigma_min = p.sigma_min
rho = p.rho
print(f"\nsigma_min: {sigma_min}, sigma_max: {sigma_max}, rho: {rho}")
sigmas = k_diffusion.sampling.get_sigmas_karras(n=steps, sigma_min=sigma_min, sigma_max=sigma_max, rho=rho, device=shared.device)
elif self.config is not None and self.config.options.get('scheduler', None) == 'karras':
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())