lllyasviel commited on
Commit
a770fa7
·
1 Parent(s): 827a7ed
Files changed (1) hide show
  1. modules/samplers_advanced.py +1 -35
modules/samplers_advanced.py CHANGED
@@ -152,41 +152,7 @@ class KSamplerWithRefiner:
152
  extra_args=extra_args, noise_mask=denoise_mask, callback=callback,
153
  variant='bh2', disable=disable_pbar)
154
  elif self.sampler == "ddim":
155
- timesteps = []
156
- for s in range(sigmas.shape[0]):
157
- timesteps.insert(0, self.model_wrap.sigma_to_discrete_timestep(sigmas[s]))
158
- noise_mask = None
159
- if denoise_mask is not None:
160
- noise_mask = 1.0 - denoise_mask
161
-
162
- ddim_callback = None
163
- if callback is not None:
164
- total_steps = len(timesteps) - 1
165
- ddim_callback = lambda pred_x0, i: callback(i, pred_x0, None, total_steps)
166
-
167
- sampler = DDIMSampler(self.model, device=self.device)
168
- sampler.make_schedule_timesteps(ddim_timesteps=timesteps, verbose=False)
169
- z_enc = sampler.stochastic_encode(latent_image,
170
- torch.tensor([len(timesteps) - 1] * noise.shape[0]).to(self.device),
171
- noise=noise, max_denoise=max_denoise)
172
- samples, _ = sampler.sample_custom(ddim_timesteps=timesteps,
173
- conditioning=positive,
174
- batch_size=noise.shape[0],
175
- shape=noise.shape[1:],
176
- verbose=False,
177
- unconditional_guidance_scale=cfg,
178
- unconditional_conditioning=negative,
179
- eta=0.0,
180
- x_T=z_enc,
181
- x0=latent_image,
182
- img_callback=ddim_callback,
183
- denoise_function=self.model_wrap.predict_eps_discrete_timestep,
184
- extra_args=extra_args,
185
- mask=noise_mask,
186
- to_zero=sigmas[-1] == 0,
187
- end_step=sigmas.shape[0] - 1,
188
- disable_pbar=disable_pbar)
189
-
190
  else:
191
  extra_args["denoise_mask"] = denoise_mask
192
  self.model_k.latent_image = latent_image
 
152
  extra_args=extra_args, noise_mask=denoise_mask, callback=callback,
153
  variant='bh2', disable=disable_pbar)
154
  elif self.sampler == "ddim":
155
+ raise NotImplementedError('Swapped Refiner Does not support DDIM.')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  else:
157
  extra_args["denoise_mask"] = denoise_mask
158
  self.model_k.latent_image = latent_image