Generate samples, returning intermediate images Useful for visualizing how denoised images evolve over time Args: repeat_noise_steps (int): Number of denoising timesteps in which the same noise is used across the batch. If >= 0, the initial noise is the
(self, denoise_fn, shape, device, freq,
noise_fn=torch.randn,clip_denoised=True, keep_running=False)
| 265 | return img_t |
| 266 | |
| 267 | def p_sample_loop_trajectory(self, denoise_fn, shape, device, freq, |
| 268 | noise_fn=torch.randn,clip_denoised=True, keep_running=False): |
| 269 | """ |
| 270 | Generate samples, returning intermediate images |
| 271 | Useful for visualizing how denoised images evolve over time |
| 272 | Args: |
| 273 | repeat_noise_steps (int): Number of denoising timesteps in which the same noise |
| 274 | is used across the batch. If >= 0, the initial noise is the same for all batch elemements. |
| 275 | """ |
| 276 | assert isinstance(shape, (tuple, list)) |
| 277 | |
| 278 | total_steps = self.num_timesteps if not keep_running else len(self.betas) |
| 279 | |
| 280 | img_t = noise_fn(size=shape, dtype=torch.float, device=device) |
| 281 | imgs = [img_t] |
| 282 | for t in reversed(range(0,total_steps)): |
| 283 | |
| 284 | t_ = torch.empty(shape[0], dtype=torch.int64, device=device).fill_(t) |
| 285 | img_t = self.p_sample(denoise_fn=denoise_fn, data=img_t, t=t_, noise_fn=noise_fn, |
| 286 | clip_denoised=clip_denoised, |
| 287 | return_pred_xstart=False) |
| 288 | if t % freq == 0 or t == total_steps-1: |
| 289 | imgs.append(img_t) |
| 290 | |
| 291 | assert imgs[-1].shape == shape |
| 292 | return imgs |
| 293 | |
| 294 | '''losses''' |
| 295 |
no test coverage detected