MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / decode

Method decode

cldm/ddim_hacked.py:298–317  ·  view source on GitHub ↗
(self, x_latent, cond, t_start, unconditional_guidance_scale=1.0, unconditional_conditioning=None,
               use_original_steps=False, callback=None)

Source from the content-addressed store, hash-verified

296
297 @torch.no_grad()
298 def decode(self, x_latent, cond, t_start, unconditional_guidance_scale=1.0, unconditional_conditioning=None,
299 use_original_steps=False, callback=None):
300
301 timesteps = np.arange(self.ddpm_num_timesteps) if use_original_steps else self.ddim_timesteps
302 timesteps = timesteps[:t_start]
303
304 time_range = np.flip(timesteps)
305 total_steps = timesteps.shape[0]
306 print(f"Running DDIM Sampling with {total_steps} timesteps")
307
308 iterator = tqdm(time_range, desc='Decoding image', total=total_steps)
309 x_dec = x_latent
310 for i, step in enumerate(iterator):
311 index = total_steps - i - 1
312 ts = torch.full((x_latent.shape[0],), step, device=x_latent.device, dtype=torch.long)
313 x_dec, _ = self.p_sample_ddim(x_dec, cond, ts, index=index, use_original_steps=use_original_steps,
314 unconditional_guidance_scale=unconditional_guidance_scale,
315 unconditional_conditioning=unconditional_conditioning)
316 if callback: callback(i)
317 return x_dec

Callers

nothing calls this directly

Calls 1

p_sample_ddimMethod · 0.95

Tested by

no test coverage detected