diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-08-29 05:54:09 +0000 |
---|---|---|
committer | AUTOMATIC1111 <16777216c@gmail.com> | 2023-08-29 05:54:32 +0000 |
commit | 738e133b24e27ac8d7babeb4714053204636d2c8 (patch) | |
tree | 35bc5bb1c6bde57a42c80bf4e850cd480cf7c6cd /modules/sd_samplers_kdiffusion.py | |
parent | 6558716018c8e2ebe4cef5d4951d43f391151227 (diff) | |
download | stable-diffusion-webui-gfx803-738e133b24e27ac8d7babeb4714053204636d2c8.tar.gz stable-diffusion-webui-gfx803-738e133b24e27ac8d7babeb4714053204636d2c8.tar.bz2 stable-diffusion-webui-gfx803-738e133b24e27ac8d7babeb4714053204636d2c8.zip |
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
|