MCPcopy Create free account
hub / github.com/MotrixLab/ADHMR / process_human_model_output

Function process_human_model_output

ADHMR/lib/utils/preprocessing.py:244–514  ·  view source on GitHub ↗
(human_model_param, cam_param, do_flip, img_shape, img2bb_trans, rot, human_model_type, joint_img=None)

Source from the content-addressed store, hash-verified

242
243
244def process_human_model_output(human_model_param, cam_param, do_flip, img_shape, img2bb_trans, rot, human_model_type, joint_img=None):
245 if human_model_type == 'smplx':
246 human_model = smpl_x
247 rotation_valid = np.ones((smpl_x.orig_joint_num), dtype=np.float32)
248 coord_valid = np.ones((smpl_x.joint_num), dtype=np.float32)
249
250 root_pose, body_pose, shape, trans = human_model_param['root_pose'], human_model_param['body_pose'], \
251 human_model_param['shape'], human_model_param['trans']
252 if body_pose is None:
253 body_valid = False
254 elif (np.array(body_pose) == 0).all():
255 body_valid = False
256 else:
257 body_valid = True
258
259 if not body_valid:
260 rotation_valid[smpl_x.orig_joint_part['body']] = 0
261 coord_valid[smpl_x.joint_part['body']] = 0
262
263 if 'lhand_pose' in human_model_param and human_model_param['lhand_valid']:
264 lhand_pose = human_model_param['lhand_pose']
265 else:
266 lhand_pose = np.zeros((3 * len(smpl_x.orig_joint_part['lhand'])), dtype=np.float32)
267 rotation_valid[smpl_x.orig_joint_part['lhand']] = 0
268 coord_valid[smpl_x.joint_part['lhand']] = 0
269 if 'rhand_pose' in human_model_param and human_model_param['rhand_valid']:
270 rhand_pose = human_model_param['rhand_pose']
271 else:
272 rhand_pose = np.zeros((3 * len(smpl_x.orig_joint_part['rhand'])), dtype=np.float32)
273 rotation_valid[smpl_x.orig_joint_part['rhand']] = 0
274 coord_valid[smpl_x.joint_part['rhand']] = 0
275 if 'jaw_pose' in human_model_param and 'expr' in human_model_param and human_model_param['face_valid']:
276 jaw_pose = human_model_param['jaw_pose']
277 expr = human_model_param['expr']
278 expr_valid = True
279 else:
280 jaw_pose = np.zeros((3), dtype=np.float32)
281 expr = np.zeros((smpl_x.expr_code_dim), dtype=np.float32)
282 rotation_valid[smpl_x.orig_joint_part['face']] = 0
283 coord_valid[smpl_x.joint_part['face']] = 0
284 expr_valid = False
285 if 'gender' in human_model_param:
286 gender = human_model_param['gender']
287 else:
288 gender = 'neutral'
289 root_pose = torch.FloatTensor(root_pose).view(1, 3) # (1,3)
290 body_pose = torch.FloatTensor(body_pose).view(-1, 3) # (21,3)
291 lhand_pose = torch.FloatTensor(lhand_pose).view(-1, 3) # (15,3)
292 rhand_pose = torch.FloatTensor(rhand_pose).view(-1, 3) # (15,3)
293 jaw_pose = torch.FloatTensor(jaw_pose).view(-1, 3) # (1,3)
294 shape = torch.FloatTensor(shape).view(1, -1) # SMPLX shape parameter
295 expr = torch.FloatTensor(expr).view(1, -1) # SMPLX expression parameter
296 trans = torch.FloatTensor(trans).view(1, -1) # translation vector
297
298 # apply camera extrinsic (rotation)
299 # merge root pose and camera rotation
300 if 'R' in cam_param:
301 R = np.array(cam_param['R'], dtype=np.float32).reshape(3, 3)

Callers 1

__getitem__Method · 0.90

Calls 1

cam2pixelFunction · 0.90

Tested by

no test coverage detected