diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-08-29 08:54:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-29 08:54:09 +0300 |
commit | 01a257eb0703632ac8cf0500a120992a1808b766 (patch) | |
tree | fc2a0dfc07194a71bcf665aa30652f6d605a40f3 /modules/sd_samplers_kdiffusion.py | |
parent | 9c87ae0d9db7007960d9de72b56799ec72f60ad5 (diff) | |
parent | 7ab16e99eedf3b5da7e596218a585f6966aee4d8 (diff) |
Merge pull request #12818 from catboxanon/sgm
Add option to align with sgm repo's sampling implementation
Diffstat (limited to 'modules/sd_samplers_kdiffusion.py')
-rw-r--r-- | modules/sd_samplers_kdiffusion.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/modules/sd_samplers_kdiffusion.py b/modules/sd_samplers_kdiffusion.py index b9e0d577..a8a2735f 100644 --- a/modules/sd_samplers_kdiffusion.py +++ b/modules/sd_samplers_kdiffusion.py @@ -144,7 +144,13 @@ class KDiffusionSampler(sd_samplers_common.Sampler): sigmas = self.get_sigmas(p, steps)
sigma_sched = sigmas[steps - t_enc - 1:]
- xi = x + noise * sigma_sched[0]
+ if opts.sgm_noise_multiplier:
+ p.extra_generation_params["SGM noise multiplier"] = True
+ noise_multiplier = torch.sqrt(1.0 + sigma_sched[0] ** 2.0)
+ else:
+ noise_multiplier = sigma_sched[0]
+
+ xi = x + noise * noise_multiplier
if opts.img2img_extra_noise > 0:
p.extra_generation_params["Extra noise"] = opts.img2img_extra_noise
@@ -197,7 +203,11 @@ class KDiffusionSampler(sd_samplers_common.Sampler): sigmas = self.get_sigmas(p, steps)
- x = x * sigmas[0]
+ if opts.sgm_noise_multiplier:
+ p.extra_generation_params["SGM noise multiplier"] = True
+ x = x * torch.sqrt(1.0 + sigmas[0] ** 2.0)
+ else:
+ x = x * sigmas[0]
extra_params_kwargs = self.initialize(p)
parameters = inspect.signature(self.func).parameters
|