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

Method forward

ldm/models/diffusion/ddpm.py:847–856  ·  view source on GitHub ↗
(self, x, c, *args, **kwargs)

Source from the content-addressed store, hash-verified

845 return loss
846
847 def forward(self, x, c, *args, **kwargs):
848 t = torch.randint(0, self.num_timesteps, (x.shape[0],), device=self.device).long()
849 if self.model.conditioning_key is not None:
850 assert c is not None
851 if self.cond_stage_trainable:
852 c = self.get_learned_conditioning(c)
853 if self.shorten_cond_schedule: # TODO: drop this option
854 tc = self.cond_ids[t].to(self.device)
855 c = self.q_sample(x_start=c, t=tc, noise=torch.randn_like(c.float()))
856 return self.p_losses(x, c, t, *args, **kwargs)
857
858 def apply_model(self, x_noisy, t, cond, return_ids=False):
859 if isinstance(cond, dict):

Callers

nothing calls this directly

Calls 3

p_lossesMethod · 0.95
q_sampleMethod · 0.45

Tested by

no test coverage detected