MCPcopy Create free account
hub / github.com/MotrixLab/insactor / forward

Method forward

diffplanner/models/transformers/actor.py:80–117  ·  view source on GitHub ↗
(self, motion, motion_mask=None, condition=None)

Source from the content-addressed store, hash-verified

78
79 # KIT
80 def forward(self, motion, motion_mask=None, condition=None):
81 motion = motion[:, :, :self.input_feats].float()
82 B, T = motion.shape[:2]
83 motion = motion.view(B, T, -1)
84 feature = self.skelEmbedding(motion)
85 if self.use_condition:
86 if self.output_var:
87 if self.num_class is None:
88 sigma_query = self.sigma_layer(condition).view(B, 1, -1)
89 else:
90 sigma_query = self.sigma_layer[condition.long()].view(B, 1, -1)
91 feature = torch.cat((sigma_query, feature), dim=1)
92 if self.num_class is None:
93 mu_query = self.mu_layer(condition).view(B, 1, -1)
94 else:
95 mu_query = self.mu_layer[condition.long()].view(B, 1, -1)
96 feature = torch.cat((mu_query, feature), dim=1)
97 else:
98 query = self.query.view(1, -1, self.latent_dim).repeat(B, 1, 1)
99 feature = torch.cat((query, feature), dim=1)
100 if self.output_var:
101 motion_mask = torch.cat((torch.ones(B, 2).to(motion.device), motion_mask), dim=1)
102 else:
103 motion_mask = torch.cat((torch.ones(B, 1).to(motion.device), motion_mask), dim=1)
104 feature = feature.permute(1, 0, 2).contiguous()
105 feature = self.pos_encoder(feature)
106 feature = self.seqTransEncoder(feature, src_key_padding_mask=motion_mask)
107 if self.use_final_proj:
108 mu = self.final_mu(feature[0])
109 if self.output_var:
110 sigma = self.final_sigma(feature[1])
111 return mu, sigma
112 return mu
113 else:
114 if self.output_var:
115 return feature[0], feature[1]
116 else:
117 return feature[0]
118
119 # # Human
120 # def forward(self, motion, motion_length=None, motion_mask=None, condition=None):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected