[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>
This commit is contained in:
nicolas-dufour 2022-08-29 15:40:49 +01:00 committed by GitHub
parent 9e1b1ca49d
commit da7d4cf200
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions

View File

@ -124,10 +124,8 @@ class LMSDiscreteScheduler(SchedulerMixin, ConfigMixin):
return {"prev_sample": prev_sample}
def add_noise(self, original_samples, noise, timesteps):
alpha_prod = self.alphas_cumprod[timesteps]
alpha_prod = self.match_shape(alpha_prod, original_samples)
noisy_samples = (alpha_prod**0.5) * original_samples + ((1 - alpha_prod) ** 0.5) * noise
sigmas = self.match_shape(self.sigmas, noise)
noisy_samples = original_samples + noise * sigmas[timesteps]
return noisy_samples
def __len__(self):