| 203 | |
| 204 | |
| 205 | class SMPL(object): |
| 206 | def __init__(self): |
| 207 | self.layer_arg = { |
| 208 | 'create_body_pose': False, |
| 209 | 'create_betas': False, |
| 210 | 'create_global_orient': False, |
| 211 | 'create_transl': False |
| 212 | } |
| 213 | self.layer = { |
| 214 | 'neutral': |
| 215 | smplx.create(cfg.human_model_path, |
| 216 | 'smpl', |
| 217 | gender='NEUTRAL', |
| 218 | **self.layer_arg), |
| 219 | 'male': |
| 220 | smplx.create(cfg.human_model_path, |
| 221 | 'smpl', |
| 222 | gender='MALE', |
| 223 | **self.layer_arg), |
| 224 | 'female': |
| 225 | smplx.create(cfg.human_model_path, |
| 226 | 'smpl', |
| 227 | gender='FEMALE', |
| 228 | **self.layer_arg) |
| 229 | } |
| 230 | self.vertex_num = 6890 |
| 231 | self.face = self.layer['neutral'].faces |
| 232 | self.shape_param_dim = 10 |
| 233 | self.vposer_code_dim = 32 |
| 234 | |
| 235 | # original SMPL joint set |
| 236 | self.orig_joint_num = 24 |
| 237 | self.orig_joints_name = ('Pelvis', 'L_Hip', 'R_Hip', 'Spine_1', |
| 238 | 'L_Knee', 'R_Knee', 'Spine_2', 'L_Ankle', |
| 239 | 'R_Ankle', 'Spine_3', 'L_Foot', 'R_Foot', |
| 240 | 'Neck', 'L_Collar', 'R_Collar', 'Head', |
| 241 | 'L_Shoulder', 'R_Shoulder', 'L_Elbow', |
| 242 | 'R_Elbow', 'L_Wrist', 'R_Wrist', 'L_Hand', |
| 243 | 'R_Hand') |
| 244 | self.orig_flip_pairs = ((1, 2), (4, 5), (7, 8), (10, 11), (13, 14), |
| 245 | (16, 17), (18, 19), (20, 21), (22, 23)) |
| 246 | self.orig_root_joint_idx = self.orig_joints_name.index('Pelvis') |
| 247 | self.orig_joint_regressor = self.layer['neutral'].J_regressor.numpy( |
| 248 | ).astype(np.float32) |
| 249 | |
| 250 | self.joint_num = self.orig_joint_num |
| 251 | self.joints_name = self.orig_joints_name |
| 252 | self.flip_pairs = self.orig_flip_pairs |
| 253 | self.root_joint_idx = self.orig_root_joint_idx |
| 254 | self.joint_regressor = self.orig_joint_regressor |
| 255 | self.joint_regressor_male = self.layer['male'].J_regressor.numpy( |
| 256 | ).astype(np.float32) |
| 257 | |
| 258 | smpl_x = SMPLX() |
| 259 | smpl = SMPL() |