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

Method forward

detrsmpl/models/body_models/flame.py:142–187  ·  view source on GitHub ↗

Forward function. Args: *args: extra arguments for FLAME return_verts: whether to return vertices return_full_pose: whether to return full pose parameters **kwargs: extra arguments for FLAME Returns: output: contains outpu

(self,
                *args,
                return_verts: bool = True,
                return_full_pose: bool = False,
                **kwargs)

Source from the content-addressed store, hash-verified

140 self.num_joints = get_keypoint_num(convention=self.keypoint_dst)
141
142 def forward(self,
143 *args,
144 return_verts: bool = True,
145 return_full_pose: bool = False,
146 **kwargs) -> dict:
147 """Forward function.
148
149 Args:
150 *args: extra arguments for FLAME
151 return_verts: whether to return vertices
152 return_full_pose: whether to return full pose parameters
153 **kwargs: extra arguments for FLAME
154
155 Returns:
156 output: contains output parameters and attributes
157 """
158 flame_output = super(FLAMELayer, self).forward(*args, **kwargs)
159 joints = flame_output.joints
160 joints, joint_mask = convert_kps(joints,
161 src=self.keypoint_src,
162 dst=self.keypoint_dst,
163 approximate=self.keypoint_approximate)
164 if isinstance(joint_mask, np.ndarray):
165 joint_mask = torch.tensor(joint_mask,
166 dtype=torch.uint8,
167 device=joints.device)
168
169 batch_size = joints.shape[0]
170 joint_mask = joint_mask.reshape(1, -1).expand(batch_size, -1)
171
172 output = dict(global_orient=flame_output.global_orient,
173 neck_pose=flame_output.neck_pose,
174 jaw_pose=flame_output.jaw_pose,
175 joints=joints,
176 joint_mask=joint_mask,
177 keypoints=torch.cat([joints, joint_mask[:, :, None]],
178 dim=-1),
179 betas=flame_output.betas,
180 expression=flame_output.expression)
181
182 if return_verts:
183 output['vertices'] = flame_output.vertices
184 if return_full_pose:
185 output['full_pose'] = flame_output.full_pose
186
187 return output

Callers

nothing calls this directly

Calls 2

convert_kpsFunction · 0.90
forwardMethod · 0.45

Tested by

no test coverage detected