Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
christsa committed Sep 23, 2024
1 parent 8014e7d commit 5fd7d69
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
7 changes: 2 additions & 5 deletions aitviewer/models/smpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ def fk_mano(
if trans is None:
trans = torch.zeros([batch_size, 3]).to(dtype=hand_pose.dtype, device=device)


# Batch shapes if they don't match batch dimension.
if len(betas.shape) == 1 or betas.shape[0] == 1:
betas = betas.repeat(hand_pose.shape[0], 1)
Expand All @@ -281,23 +280,21 @@ def fk_mano(
trans = torch.matmul(first_root_ori.unsqueeze(0), trans.unsqueeze(-1)).squeeze()
trans = trans - trans[0:1]


output = self.bm(
hand_pose=hand_pose,
betas=betas,
global_orient=global_orient,
transl=trans,
)


return output.vertices, output.joints

def forward(self, *args, **kwargs):
"""
Forward pass using forward kinematics
"""

if 'mano' in kwargs.keys():
if "mano" in kwargs.keys():
return self.fk_mano(*args, **kwargs)
else:
return self.fk(*args, **kwargs)
return self.fk(*args, **kwargs)
2 changes: 1 addition & 1 deletion aitviewer/renderables/meshes.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(
draw_edges=False,
draw_outline=False,
instance_transforms=None,
z_up = False,
z_up=False,
icon="\u008d",
**kwargs,
):
Expand Down
22 changes: 12 additions & 10 deletions aitviewer/renderables/smpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ def __init__(
# Nodes
self.vertices, self.joints, self.faces, self.skeleton = self.fk()


if self._is_rigged:
self.skeleton_seq = Skeletons(
self.joints,
Expand Down Expand Up @@ -177,7 +176,6 @@ def __init__(
if self._z_up and not C.z_up:
self.rotation = np.matmul(np.array([[1, 0, 0], [0, 0, 1], [0, -1, 0]]), self.rotation)


if self.smpl_layer.model_type != "mano":
self.rbs = RigidBodies(self.joints, global_oris, length=0.1, gui_affine=False, name="Joint Angles")
self._add_node(self.rbs, enabled=self._show_joint_angles)
Expand Down Expand Up @@ -406,15 +404,15 @@ def fk(self, current_frame_only=False):
poses_right_hand = self.poses_right_hand
trans = self.trans
betas = self.betas

if self.smpl_layer.model_type == "mano":
verts, joints = self.smpl_layer(
hand_pose=poses_body,
betas=betas,
global_orient=poses_root,
trans=trans,
mano=True,
)
hand_pose=poses_body,
betas=betas,
global_orient=poses_root,
trans=trans,
mano=True,
)
else:
verts, joints = self.smpl_layer(
poses_root=poses_root,
Expand All @@ -429,7 +427,11 @@ def fk(self, current_frame_only=False):
if self.post_fk_func:
verts, joints = self.post_fk_func(self, verts, joints, current_frame_only)

skeleton = self.smpl_layer.skeletons()["body"].T if not self.smpl_layer.model_type == "mano" else self.smpl_layer.skeletons()["all"].T
skeleton = (
self.smpl_layer.skeletons()["body"].T
if not self.smpl_layer.model_type == "mano"
else self.smpl_layer.skeletons()["all"].T
)
faces = self.smpl_layer.bm.faces.astype(np.int64)
joints = joints[:, : skeleton.shape[0]]

Expand Down

0 comments on commit 5fd7d69

Please sign in to comment.