Skip to content

Commit

Permalink
Revert "fix alphas cumprod (#475)"
Browse files Browse the repository at this point in the history
This reverts commit 72139b0.
  • Loading branch information
lllyasviel authored Mar 4, 2024
1 parent 72139b0 commit 95bcea7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
8 changes: 1 addition & 7 deletions ldm_patched/modules/model_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,7 @@ def sigma_max(self):
def timestep(self, sigma):
log_sigma = sigma.log()
dists = log_sigma.to(self.log_sigmas.device) - self.log_sigmas[:, None]
low_idx = dists.ge(0).cumsum(dim=0).argmax(dim=0).clamp(max=self.log_sigmas.shape[0] - 2)
high_idx = low_idx + 1
low, high = self.log_sigmas[low_idx], self.log_sigmas[high_idx]
w = (low - log_sigma) / (low - high)
w = w.clamp(0, 1)
t = (1 - w) * low_idx + w * high_idx
return t.view(sigma.shape)
return dists.abs().argmin(dim=0).view(sigma.shape).to(sigma.device)

def sigma(self, timestep):
t = torch.clamp(timestep.float().to(self.log_sigmas.device), min=0, max=(len(self.sigmas) - 1))
Expand Down
2 changes: 0 additions & 2 deletions modules/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,13 +917,11 @@ def rescale_zero_terminal_snr_abar(alphas_cumprod):
alphas_cumprod_backup = p.sd_model.alphas_cumprod
for modifier in alphas_cumprod_modifiers:
p.sd_model.alphas_cumprod = modifier(p.sd_model.alphas_cumprod)
p.sd_model.forge_objects.unet.model.model_sampling.set_sigmas(((1 - p.sd_model.alphas_cumprod) / p.sd_model.alphas_cumprod) ** 0.5)

samples_ddim = p.sample(conditioning=p.c, unconditional_conditioning=p.uc, seeds=p.seeds, subseeds=p.subseeds, subseed_strength=p.subseed_strength, prompts=p.prompts)

if alphas_cumprod_backup is not None:
p.sd_model.alphas_cumprod = alphas_cumprod_backup
p.sd_model.forge_objects.unet.model.model_sampling.set_sigmas(((1 - p.sd_model.alphas_cumprod) / p.sd_model.alphas_cumprod) ** 0.5)

if p.scripts is not None:
ps = scripts.PostSampleArgs(samples_ddim)
Expand Down

0 comments on commit 95bcea7

Please sign in to comment.