MCPcopy Index your code
hub / github.com/CompVis/diff2flow / make_ddim_timesteps

Function make_ddim_timesteps

diff2flow/ddim.py:18–34  ·  view source on GitHub ↗
(ddim_discr_method, num_ddim_timesteps, num_ddpm_timesteps, verbose=True)

Source from the content-addressed store, hash-verified

16
17
18def make_ddim_timesteps(ddim_discr_method, num_ddim_timesteps, num_ddpm_timesteps, verbose=True):
19 if ddim_discr_method == 'uniform':
20 c = num_ddpm_timesteps // num_ddim_timesteps
21 assert c > 1, "Issue, not solved!"
22 ddim_timesteps = np.asarray(list(range(0, num_ddpm_timesteps, c)))
23 elif ddim_discr_method == 'quad':
24 ddim_timesteps = ((np.linspace(0, np.sqrt(num_ddpm_timesteps * .8), num_ddim_timesteps)) ** 2).astype(int)
25 else:
26 raise NotImplementedError(f'There is no ddim discretization method called "{ddim_discr_method}"')
27
28 # assert ddim_timesteps.shape[0] == num_ddim_timesteps
29 # add one to get the final alpha values right (the ones from first scale to data during sampling)
30 steps_out = ddim_timesteps + 1
31 if verbose:
32 print(f'Selected timesteps for ddim sampler: {steps_out}')
33
34 return steps_out
35
36
37def make_ddim_sampling_parameters(alphacums, ddim_timesteps, eta, verbose=True):

Callers 1

make_scheduleMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected