Skip to content

Commit b50a9ae

Browse files
[Stable diffusion] Hot fix
1 parent ea2e177 commit b50a9ae

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ def __call__(
9696

9797
self.scheduler.set_timesteps(num_inference_steps, **extra_set_kwargs)
9898

99+
# if we use LMSDiscreteScheduler, let's make sure latents are mulitplied by sigmas
100+
if isinstance(self.scheduler, LMSDiscreteScheduler):
101+
latents = latents * self.scheduler.sigmas[0]
102+
99103
# prepare extra kwargs for the scheduler step, since not all schedulers have the same signature
100104
# eta (η) is only used with the DDIMScheduler, it will be ignored for other schedulers.
101105
# eta corresponds to η in DDIM paper: https://arxiv.org/abs/2010.02502
@@ -105,10 +109,6 @@ def __call__(
105109
if accepts_eta:
106110
extra_step_kwargs["eta"] = eta
107111

108-
self.scheduler.set_timesteps(num_inference_steps)
109-
if isinstance(self.scheduler, LMSDiscreteScheduler):
110-
latents = latents * self.scheduler.sigmas[0]
111-
112112
for i, t in tqdm(enumerate(self.scheduler.timesteps)):
113113
# expand the latents if we are doing classifier free guidance
114114
latent_model_input = torch.cat([latents] * 2) if do_classifier_free_guidance else latents

src/diffusers/schedulers/scheduling_lms_discrete.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def __init__(
3636
tensor_format="pt",
3737
):
3838
"""
39-
Linear Multistep Scheduler for discrete beta schedules.
40-
Based on the original k-diffusion implementation by Katherine Crowson:
39+
Linear Multistep Scheduler for discrete beta schedules. Based on the original k-diffusion implementation by
40+
Katherine Crowson:
4141
https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L181
4242
"""
4343

0 commit comments

Comments
 (0)