From d62954c2bc149053f9f51dfe95751b9e0ea29f03 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Wed, 28 Sep 2022 22:30:52 +0300 Subject: [PATCH] fix broken DDIM with img2img --- modules/sd_samplers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/sd_samplers.py b/modules/sd_samplers.py index 3588aae6..fc0c94b4 100644 --- a/modules/sd_samplers.py +++ b/modules/sd_samplers.py @@ -136,6 +136,8 @@ class VanillaStableDiffusionSampler: def sample_img2img(self, p, x, noise, conditioning, unconditional_conditioning, steps=None): steps, t_enc = setup_img2img_steps(p, steps) + self.initialize(p) + # existing code fails with cetain step counts, like 9 try: self.sampler.make_schedule(ddim_num_steps=steps, ddim_eta=self.eta, ddim_discretize=p.ddim_discretize, verbose=False) @@ -144,8 +146,6 @@ class VanillaStableDiffusionSampler: x1 = self.sampler.stochastic_encode(x, torch.tensor([t_enc] * int(x.shape[0])).to(shared.device), noise=noise) - self.initialize(p) - self.init_latent = x self.step = 0