run make_schedule() if it hasn't already been called

- fixes #984
This commit is contained in:
Lincoln Stein 2022-10-09 15:29:04 -04:00
parent ce8c238ac4
commit 318eb35ea0
2 changed files with 17 additions and 0 deletions

View File

@ -171,6 +171,14 @@ class KSampler(Sampler):
if img_callback is not None:
img_callback(k_callback_values['x'],k_callback_values['i'])
# if make_schedule() hasn't been called, we do it now
if self.sigmas is None:
self.make_schedule(
ddim_num_steps=S,
ddim_eta = eta,
verbose = False,
)
# sigmas are set up in make_schedule - we take the last steps items
total_steps = len(self.sigmas)
sigmas = self.sigmas[-S-1:]

View File

@ -20,6 +20,7 @@ from ldm.modules.diffusionmodules.util import (
class Sampler(object):
def __init__(self, model, schedule='linear', steps=None, device=None, **kwargs):
self.model = model
self.ddim_timesteps = None
self.ddpm_num_timesteps = steps
self.schedule = schedule
self.device = device or choose_torch_device()
@ -157,6 +158,14 @@ class Sampler(object):
**kwargs,
):
# check to see if make_schedule() has run, and if not, run it
if self.ddim_timesteps is None:
self.make_schedule(
ddim_num_steps=S,
ddim_eta = eta,
verbose = False,
)
ts = self.get_timesteps(S)
# sampling