(self, x_latent, cond, t_start, unconditional_guidance_scale=1.0, unconditional_conditioning=None,
use_original_steps=False, callback=None)
| 315 | |
| 316 | @torch.no_grad() |
| 317 | def decode(self, x_latent, cond, t_start, unconditional_guidance_scale=1.0, unconditional_conditioning=None, |
| 318 | use_original_steps=False, callback=None): |
| 319 | |
| 320 | timesteps = np.arange(self.ddpm_num_timesteps) if use_original_steps else self.ddim_timesteps |
| 321 | timesteps = timesteps[:t_start] |
| 322 | |
| 323 | time_range = np.flip(timesteps) |
| 324 | total_steps = timesteps.shape[0] |
| 325 | print(f"Running DDIM Sampling with {total_steps} timesteps") |
| 326 | |
| 327 | iterator = tqdm(time_range, desc='Decoding image', total=total_steps) |
| 328 | x_dec = x_latent |
| 329 | for i, step in enumerate(iterator): |
| 330 | index = total_steps - i - 1 |
| 331 | ts = torch.full((x_latent.shape[0],), step, device=x_latent.device, dtype=torch.long) |
| 332 | x_dec, _ = self.p_sample_ddim(x_dec, cond, ts, index=index, use_original_steps=use_original_steps, |
| 333 | unconditional_guidance_scale=unconditional_guidance_scale, |
| 334 | unconditional_conditioning=unconditional_conditioning) |
| 335 | if callback: callback(i) |
| 336 | return x_dec |
no test coverage detected