@@ -96,7 +96,7 @@ def __init__(
9696
9797 # setable values
9898 self .num_inference_steps = None
99- self .timesteps = np .arange (0 , num_train_timesteps )[::- 1 ]. copy ()
99+ self .timesteps = np .arange (0 , num_train_timesteps )[::- 1 ] # to be consistent has to be smaller than sigmas by 1
100100 self .derivatives = []
101101
102102 def get_lms_coefficient (self , order , t , current_order ):
@@ -130,16 +130,17 @@ def set_timesteps(self, num_inference_steps: int):
130130 the number of diffusion steps used when generating samples with a pre-trained model.
131131 """
132132 self .num_inference_steps = num_inference_steps
133- self . timesteps = np .linspace (self .config .num_train_timesteps - 1 , 0 , num_inference_steps , dtype = float )
133+ timesteps = np .linspace (self .config .num_train_timesteps - 1 , 0 , num_inference_steps , dtype = float )
134134
135- low_idx = np .floor (self . timesteps ).astype (int )
136- high_idx = np .ceil (self . timesteps ).astype (int )
137- frac = np .mod (self . timesteps , 1.0 )
135+ low_idx = np .floor (timesteps ).astype (int )
136+ high_idx = np .ceil (timesteps ).astype (int )
137+ frac = np .mod (timesteps , 1.0 )
138138 sigmas = np .array (((1 - self .alphas_cumprod ) / self .alphas_cumprod ) ** 0.5 )
139139 sigmas = (1 - frac ) * sigmas [low_idx ] + frac * sigmas [high_idx ]
140140 sigmas = np .concatenate ([sigmas , [0.0 ]]).astype (np .float32 )
141141 self .sigmas = torch .from_numpy (sigmas )
142142
143+ self .timesteps = timesteps .astype (int )
143144 self .derivatives = []
144145
145146 def step (
0 commit comments