Correct timestep for img2img initial noise addition (#1946)

* Correct timestep for img2img initial noise addition

* apply fix to inpaint and txt2img2img as well

Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
This commit is contained in:
wfng92 2022-12-16 04:59:19 +08:00 committed by GitHub
parent 7a4e647287
commit 2a2f38a016
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -45,7 +45,7 @@ class Img2Img(Generator):
# encode (scaled latent)
z_enc = sampler.stochastic_encode(
self.init_latent,
torch.tensor([t_enc]).to(self.model.device),
torch.tensor([t_enc - 1]).to(self.model.device),
noise=x_T
)

View File

@ -279,7 +279,7 @@ class Inpaint(Img2Img):
# encode (scaled latent)
z_enc = sampler.stochastic_encode(
self.init_latent,
torch.tensor([t_enc]).to(self.model.device),
torch.tensor([t_enc - 1]).to(self.model.device),
noise=x_T
)

View File

@ -84,7 +84,7 @@ class Txt2Img2Img(Generator):
z_enc = ddim_sampler.stochastic_encode(
samples,
torch.tensor([t_enc]).to(self.model.device),
torch.tensor([t_enc-1]).to(self.model.device),
noise=self.get_noise(width,height,False)
)