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

Function process_human_model_output

HMR-Scorer/common/utils/preprocessing.py:323–593  ·  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

321
322
323def process_human_model_output(human_model_param, cam_param, do_flip, img_shape, img2bb_trans, rot, human_model_type, joint_img=None):
324 if human_model_type == 'smplx':
325 human_model = smpl_x
326 rotation_valid = np.ones((smpl_x.orig_joint_num), dtype=np.float32)
327 coord_valid = np.ones((smpl_x.joint_num), dtype=np.float32)
328
329 root_pose, body_pose, shape, trans = human_model_param['root_pose'], human_model_param['body_pose'], \
330 human_model_param['shape'], human_model_param['trans']
331 if body_pose is None:
332 body_valid = False
333 elif (np.array(body_pose) == 0).all():
334 body_valid = False
335 else:
336 body_valid = True
337
338 if not body_valid:
339 rotation_valid[smpl_x.orig_joint_part['body']] = 0
340 coord_valid[smpl_x.joint_part['body']] = 0
341
342 if 'lhand_pose' in human_model_param and human_model_param['lhand_valid']:
343 lhand_pose = human_model_param['lhand_pose']
344 else:
345 lhand_pose = np.zeros((3 * len(smpl_x.orig_joint_part['lhand'])), dtype=np.float32)
346 rotation_valid[smpl_x.orig_joint_part['lhand']] = 0
347 coord_valid[smpl_x.joint_part['lhand']] = 0
348 if 'rhand_pose' in human_model_param and human_model_param['rhand_valid']:
349 rhand_pose = human_model_param['rhand_pose']
350 else:
351 rhand_pose = np.zeros((3 * len(smpl_x.orig_joint_part['rhand'])), dtype=np.float32)
352 rotation_valid[smpl_x.orig_joint_part['rhand']] = 0
353 coord_valid[smpl_x.joint_part['rhand']] = 0
354 if 'jaw_pose' in human_model_param and 'expr' in human_model_param and human_model_param['face_valid']:
355 jaw_pose = human_model_param['jaw_pose']
356 expr = human_model_param['expr']
357 expr_valid = True
358 else:
359 jaw_pose = np.zeros((3), dtype=np.float32)
360 expr = np.zeros((smpl_x.expr_code_dim), dtype=np.float32)
361 rotation_valid[smpl_x.orig_joint_part['face']] = 0
362 coord_valid[smpl_x.joint_part['face']] = 0
363 expr_valid = False
364 if 'gender' in human_model_param:
365 gender = human_model_param['gender']
366 else:
367 gender = 'neutral'
368 root_pose = torch.FloatTensor(root_pose).view(1, 3) # (1,3)
369 body_pose = torch.FloatTensor(body_pose).view(-1, 3) # (21,3)
370 lhand_pose = torch.FloatTensor(lhand_pose).view(-1, 3) # (15,3)
371 rhand_pose = torch.FloatTensor(rhand_pose).view(-1, 3) # (15,3)
372 jaw_pose = torch.FloatTensor(jaw_pose).view(-1, 3) # (1,3)
373 shape = torch.FloatTensor(shape).view(1, -1) # SMPLX shape parameter
374 expr = torch.FloatTensor(expr).view(1, -1) # SMPLX expression parameter
375 trans = torch.FloatTensor(trans).view(1, -1) # translation vector
376
377 # apply camera extrinsic (rotation)
378 # merge root pose and camera rotation
379 if 'R' in cam_param:
380 R = np.array(cam_param['R'], dtype=np.float32).reshape(3, 3)

Callers 5

__getitem__Method · 0.90
__getitem__Method · 0.90
__getitem__Method · 0.90
__getitem__Method · 0.90
__getitem__Method · 0.90

Calls 1

cam2pixelFunction · 0.90

Tested by 1

__getitem__Method · 0.72