MCPcopy Index your code
hub / github.com/VisionXLab/OF-Diff / stochastic_encode

Method stochastic_encode

cldm/ddim_hacked.py:282–295  ·  view source on GitHub ↗
(self, x0, t, use_original_steps=False, noise=None)

Source from the content-addressed store, hash-verified

280
281 @torch.no_grad()
282 def stochastic_encode(self, x0, t, use_original_steps=False, noise=None):
283 # fast, but does not allow for exact reconstruction
284 # t serves as an index to gather the correct alphas
285 if use_original_steps:
286 sqrt_alphas_cumprod = self.sqrt_alphas_cumprod
287 sqrt_one_minus_alphas_cumprod = self.sqrt_one_minus_alphas_cumprod
288 else:
289 sqrt_alphas_cumprod = torch.sqrt(self.ddim_alphas)
290 sqrt_one_minus_alphas_cumprod = self.ddim_sqrt_one_minus_alphas
291
292 if noise is None:
293 noise = torch.randn_like(x0)
294 return (extract_into_tensor(sqrt_alphas_cumprod, t, x0.shape) * x0 +
295 extract_into_tensor(sqrt_one_minus_alphas_cumprod, t, x0.shape) * noise)
296
297 @torch.no_grad()
298 def decode(self, x_latent, cond, t_start, unconditional_guidance_scale=1.0, unconditional_conditioning=None,

Callers

nothing calls this directly

Calls 1

extract_into_tensorFunction · 0.90

Tested by

no test coverage detected