Skip to content

Commit c66604b

Browse files
author
rupert
committed
fix huggingface#3487 initial latents are now only scaled by init_noise_sigma when pure noise
updated this commit w.r.t the latest merge here: huggingface#3533
1 parent 17e6f2b commit c66604b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,13 +648,13 @@ def prepare_latents(
648648

649649
if latents is None:
650650
noise = randn_tensor(shape, generator=generator, device=device, dtype=dtype)
651+
# if strength is 1. then initialise the latents to noise, else initial to image + noise
651652
latents = noise if is_strength_max else self.scheduler.add_noise(image_latents, noise, timestep)
653+
# if pure noise then scale the initial latents by the Scheduler's init sigma
654+
latents = latents * self.scheduler.init_noise_sigma if is_strength_max else latents
652655
else:
653656
latents = latents.to(device)
654657

655-
# scale the initial noise by the standard deviation required by the scheduler
656-
latents = latents * self.scheduler.init_noise_sigma
657-
658658
outputs = (latents,)
659659

660660
if return_noise:

0 commit comments

Comments
 (0)