From 0b44aad16e4f5c48c13d8af7f4a7e6cbc9802d8b Mon Sep 17 00:00:00 2001 From: qcloud Date: Sun, 26 Nov 2023 17:05:47 +0800 Subject: [PATCH] Fix a bug --- ldm/modules/diffusionmodules/util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ldm/modules/diffusionmodules/util.py b/ldm/modules/diffusionmodules/util.py index daf35da7..6c00b087 100644 --- a/ldm/modules/diffusionmodules/util.py +++ b/ldm/modules/diffusionmodules/util.py @@ -70,7 +70,9 @@ def make_ddim_timesteps(ddim_discr_method, num_ddim_timesteps, num_ddpm_timestep def make_ddim_sampling_parameters(alphacums, ddim_timesteps, eta, verbose=True): # select alphas for computing the variance schedule alphas = alphacums[ddim_timesteps] - alphas_prev = np.asarray([alphacums[0]] + alphacums[ddim_timesteps[:-1]].tolist()) + + # alphas_prev should start with 1. + alphas_prev = np.append(1., alphas[:-1]) # according the the formula provided in https://arxiv.org/abs/2010.02502 sigmas = eta * np.sqrt((1 - alphas_prev) / (1 - alphas) * (1 - alphas / alphas_prev))