MCPcopy Index your code
hub / github.com/MotrixLab/MotionDiffuse / forward

Method forward

text2motion/trainers/ddpm_trainer.py:67–89  ·  view source on GitHub ↗
(self, batch_data, eval_mode=False)

Source from the content-addressed store, hash-verified

65 opt.step()
66
67 def forward(self, batch_data, eval_mode=False):
68 caption, motions, m_lens = batch_data
69 motions = motions.detach().to(self.device).float()
70
71 self.caption = caption
72 self.motions = motions
73 x_start = motions
74 B, T = x_start.shape[:2]
75 cur_len = torch.LongTensor([min(T, m_len) for m_len in m_lens]).to(self.device)
76 t, _ = self.sampler.sample(B, x_start.device)
77 output = self.diffusion.training_losses(
78 model=self.encoder,
79 x_start=x_start,
80 t=t,
81 model_kwargs={"text": caption, "length": cur_len}
82 )
83
84 self.real_noise = output['target']
85 self.fake_noise = output['pred']
86 try:
87 self.src_mask = self.encoder.module.generate_src_mask(T, cur_len).to(x_start.device)
88 except:
89 self.src_mask = self.encoder.generate_src_mask(T, cur_len).to(x_start.device)
90
91 def generate_batch(self, caption, m_lens, dim_pose):
92 xf_proj, xf_out = self.encoder.encode_text(caption, self.device)

Callers 1

trainMethod · 0.95

Calls 4

toMethod · 0.80
sampleMethod · 0.80
training_lossesMethod · 0.80
generate_src_maskMethod · 0.80

Tested by

no test coverage detected