MCPcopy Create free account
hub / github.com/MotrixLab/FineMoGen / MotionDiffuseTransformer

Class MotionDiffuseTransformer

mogen/models/transformers/motiondiffuse.py:9–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7
8@SUBMODULES.register_module()
9class MotionDiffuseTransformer(DiffusionTransformer):
10
11 def __init__(self, **kwargs):
12 super().__init__(**kwargs)
13
14 def get_precompute_condition(self,
15 text=None,
16 xf_proj=None,
17 xf_out=None,
18 device=None,
19 clip_feat=None,
20 **kwargs):
21 if xf_proj is None or xf_out is None:
22 xf_proj, xf_out = self.encode_text(text, clip_feat, device)
23 return {'xf_proj': xf_proj, 'xf_out': xf_out}
24
25 def post_process(self, motion):
26 if self.post_process_cfg is not None:
27 if self.post_process_cfg.get("unnormalized_infer", False):
28 mean = torch.from_numpy(
29 np.load(self.post_process_cfg['mean_path']))
30 mean = mean.type_as(motion)
31 std = torch.from_numpy(
32 np.load(self.post_process_cfg['std_path']))
33 std = std.type_as(motion)
34 motion = motion * std + mean
35 return motion
36
37 def forward_train(self,
38 h=None,
39 src_mask=None,
40 emb=None,
41 xf_out=None,
42 **kwargs):
43 B, T = h.shape[0], h.shape[1]
44 for module in self.temporal_decoder_blocks:
45 h = module(x=h, xf=xf_out, emb=emb, src_mask=src_mask)
46 output = self.out(h).view(B, T, -1).contiguous()
47 return output
48
49 def forward_test(self,
50 h=None,
51 src_mask=None,
52 emb=None,
53 xf_out=None,
54 **kwargs):
55 B, T = h.shape[0], h.shape[1]
56 for module in self.temporal_decoder_blocks:
57 h = module(x=h, xf=xf_out, emb=emb, src_mask=src_mask)
58 output = self.out(h).view(B, T, -1).contiguous()
59 return output

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected