MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / make_ddim_sampling_parameters

Function make_ddim_sampling_parameters

ldm/modules/diffusionmodules/util.py:63–74  ·  view source on GitHub ↗
(alphacums, ddim_timesteps, eta, verbose=True)

Source from the content-addressed store, hash-verified

61
62
63def make_ddim_sampling_parameters(alphacums, ddim_timesteps, eta, verbose=True):
64 # select alphas for computing the variance schedule
65 alphas = alphacums[ddim_timesteps]
66 alphas_prev = np.asarray([alphacums[0]] + alphacums[ddim_timesteps[:-1]].tolist())
67
68 # according the the formula provided in https://arxiv.org/abs/2010.02502
69 sigmas = eta * np.sqrt((1 - alphas_prev) / (1 - alphas) * (1 - alphas / alphas_prev))
70 if verbose:
71 print(f'Selected alphas for ddim sampler: a_t: {alphas}; a_(t-1): {alphas_prev}')
72 print(f'For the chosen value of eta, which is {eta}, '
73 f'this results in the following sigma_t schedule for ddim sampler {sigmas}')
74 return sigmas, alphas, alphas_prev
75
76
77def betas_for_alpha_bar(num_diffusion_timesteps, alpha_bar, max_beta=0.999):

Callers 3

make_scheduleMethod · 0.90
make_scheduleMethod · 0.90
make_scheduleMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected