Skip to content

Commit 4777b0b

Browse files
Merge branch 'master' into master
2 parents fc4de78 + 0c40fcf commit 4777b0b

12 files changed

+862
-237
lines changed

config_files/smplh2smplx_as.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
datasets:
2+
mesh_folder:
3+
data_folder: 'transfer_data/meshes/amass_sample'
4+
deformation_transfer_path: 'transfer_data/smplh2smplx_deftrafo_setup.pkl'
5+
mask_ids_fname: 'smplx_mask_ids.npy'
6+
summary_steps: 100
7+
8+
edge_fitting:
9+
per_part: False
10+
11+
optim:
12+
type: 'trust-ncg'
13+
maxiters: 100
14+
gtol: 1e-06
15+
16+
body_model:
17+
model_type: "smplx"
18+
gender: "neutral"
19+
folder: "models"
20+
use_compressed: False
21+
use_face_contour: True
22+
smplx:
23+
betas:
24+
num: 10
25+
expression:
26+
num: 10

config_files/smplh2smplx_onepose.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
datasets:
2+
mesh_folder:
3+
data_folder: 'transfer_data/meshes/amass_onepose'
4+
deformation_transfer_path: 'transfer_data/smplh2smplx_deftrafo_setup.pkl'
5+
mask_ids_fname: 'smplx_mask_ids.npy'
6+
summary_steps: 100
7+
8+
edge_fitting:
9+
per_part: False
10+
11+
optim:
12+
type: 'adam'
13+
lr: 0.1
14+
maxiters: 10000
15+
gtol: 1e-06
16+
17+
body_model:
18+
model_type: "smplx"
19+
gender: "neutral"
20+
folder: "models"
21+
use_compressed: False
22+
use_face_contour: True
23+
smplx:
24+
betas:
25+
num: 10
26+
expression:
27+
num: 10

smplx/body_models.py

+19-10
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@
3838
FLAMEOutput,
3939
find_joint_kin_chain)
4040
from .vertex_joint_selector import VertexJointSelector
41+
from collections import namedtuple
4142

43+
TensorOutput = namedtuple('TensorOutput',
44+
['vertices', 'joints', 'betas', 'expression', 'global_orient', 'body_pose', 'left_hand_pose',
45+
'right_hand_pose', 'jaw_pose', 'transl', 'full_pose'])
4246

4347
class SMPL(nn.Module):
4448

@@ -48,7 +52,7 @@ class SMPL(nn.Module):
4852

4953
def __init__(
5054
self, model_path: str,
51-
kid_template_path: str = '',
55+
kid_template_path: str = '',
5256
data_struct: Optional[Struct] = None,
5357
create_betas: bool = True,
5458
betas: Optional[Tensor] = None,
@@ -143,7 +147,9 @@ def __init__(
143147
shapedirs = data_struct.shapedirs
144148
if (shapedirs.shape[-1] < self.SHAPE_SPACE_DIM):
145149
print(f'WARNING: You are using a {self.name()} model, with only'
146-
f' {shapedirs.shape[-1]} shape coefficients.')
150+
f' {shapedirs.shape[-1]} shape coefficients.\n'
151+
f'num_betas={num_betas}, shapedirs.shape={shapedirs.shape}, '
152+
f'self.SHAPE_SPACE_DIM={self.SHAPE_SPACE_DIM}')
147153
num_betas = min(num_betas, shapedirs.shape[-1])
148154
else:
149155
num_betas = min(num_betas, self.SHAPE_SPACE_DIM)
@@ -901,7 +907,7 @@ class SMPLX(SMPLH):
901907

902908
def __init__(
903909
self, model_path: str,
904-
kid_template_path: str = '',
910+
kid_template_path: str = '',
905911
num_expression_coeffs: int = 10,
906912
create_expression: bool = True,
907913
expression: Optional[Tensor] = None,
@@ -1128,7 +1134,7 @@ def forward(
11281134
pose2rot: bool = True,
11291135
return_shaped: bool = True,
11301136
**kwargs
1131-
) -> SMPLXOutput:
1137+
) -> TensorOutput:
11321138
'''
11331139
Forward pass for the SMPLX model
11341140
@@ -1276,7 +1282,9 @@ def forward(
12761282
v_shaped = None
12771283
if return_shaped:
12781284
v_shaped = self.v_template + blend_shapes(betas, self.shapedirs)
1279-
output = SMPLXOutput(vertices=vertices if return_verts else None,
1285+
else:
1286+
v_shaped = Tensor(0)
1287+
output = TensorOutput(vertices=vertices if return_verts else None,
12801288
joints=joints,
12811289
betas=betas,
12821290
expression=expression,
@@ -1324,9 +1332,9 @@ def forward(
13241332
leye_pose: Optional[Tensor] = None,
13251333
reye_pose: Optional[Tensor] = None,
13261334
return_verts: bool = True,
1327-
return_full_pose: bool = False,
1335+
return_full_pose: bool = True,
13281336
**kwargs
1329-
) -> SMPLXOutput:
1337+
) -> TensorOutput:
13301338
'''
13311339
Forward pass for the SMPLX model
13321340
@@ -1475,7 +1483,7 @@ def forward(
14751483
joints += transl.unsqueeze(dim=1)
14761484
vertices += transl.unsqueeze(dim=1)
14771485

1478-
output = SMPLXOutput(vertices=vertices if return_verts else None,
1486+
output = TensorOutput(vertices=vertices if return_verts else Tensor(0),
14791487
joints=joints,
14801488
betas=betas,
14811489
expression=expression,
@@ -1484,8 +1492,9 @@ def forward(
14841492
left_hand_pose=left_hand_pose,
14851493
right_hand_pose=right_hand_pose,
14861494
jaw_pose=jaw_pose,
1487-
transl=transl,
1488-
full_pose=full_pose if return_full_pose else None)
1495+
transl=transl if transl != None else Tensor(0),
1496+
full_pose=full_pose if return_full_pose else Tensor(0))
1497+
14891498
return output
14901499

14911500

0 commit comments

Comments
 (0)