Skip to content

Commit da7d4cf

Browse files
[BugFix]: Fixed add_noise in LMSDiscreteScheduler (#253)
* Fixed add_noise in LMSDiscreteScheduler * Linting * Update src/diffusers/schedulers/scheduling_lms_discrete.py Co-authored-by: Anton Lozhkov <aglozhkov@gmail.com> Co-authored-by: Anton Lozhkov <aglozhkov@gmail.com>
1 parent 9e1b1ca commit da7d4cf

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/diffusers/schedulers/scheduling_lms_discrete.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,8 @@ def step(
124124
return {"prev_sample": prev_sample}
125125

126126
def add_noise(self, original_samples, noise, timesteps):
127-
alpha_prod = self.alphas_cumprod[timesteps]
128-
alpha_prod = self.match_shape(alpha_prod, original_samples)
129-
130-
noisy_samples = (alpha_prod**0.5) * original_samples + ((1 - alpha_prod) ** 0.5) * noise
127+
sigmas = self.match_shape(self.sigmas, noise)
128+
noisy_samples = original_samples + noise * sigmas[timesteps]
131129
return noisy_samples
132130

133131
def __len__(self):

0 commit comments

Comments
 (0)