MCPcopy Create free account
hub / github.com/Pixel-Talk/EHM-Tracker / decode

Method decode

src/modules/pixie/pixie_encoder.py:403–641  ·  view source on GitHub ↗

Decode model parameters to smplx vertices & joints & texture Args: param_dict: smplx parameters param_type: should be one of body/head/hand Returns: predictions: smplx predictions

(self, param_dict, param_type, extra=None,**kwargs)

Source from the content-addressed store, hash-verified

401 return param_dict
402
403 def decode(self, param_dict, param_type, extra=None,**kwargs):
404 ''' Decode model parameters to smplx vertices & joints & texture
405 Args:
406 param_dict: smplx parameters
407 param_type: should be one of body/head/hand
408 Returns:
409 predictions: smplx predictions
410 '''
411 if 'jaw_pose' in param_dict.keys() and len(param_dict['jaw_pose'].shape) == 2:
412 self.convert_pose(param_dict, param_type)
413 elif param_dict['right_wrist_pose'].shape[-1] == 6:
414 self.convert_pose(param_dict, param_type)
415
416 # concatenate body pose
417 partbody_pose = param_dict['partbody_pose']
418 param_dict['body_pose'] = torch.cat(
419 [partbody_pose[:, :11],
420 param_dict['neck_pose'],
421 partbody_pose[:, 11:11+2],
422 param_dict['head_pose'],
423 partbody_pose[:, 13:13+4],
424 param_dict['left_wrist_pose'],
425 param_dict['right_wrist_pose']], dim=1)
426
427 # change absolute head&hand pose to relative pose according to rest body pose
428 if param_type == 'head' or param_type == 'body':
429 param_dict['body_pose'] = self.smplx.pose_abs2rel(
430 param_dict['global_pose'],
431 param_dict['body_pose'],
432 abs_joint='head')
433 if param_type == 'hand' or param_type == 'body':
434 param_dict['body_pose'] = self.smplx.pose_abs2rel(
435 param_dict['global_pose'],
436 param_dict['body_pose'],
437 abs_joint='left_wrist')
438 param_dict['body_pose'] = self.smplx.pose_abs2rel(
439 param_dict['global_pose'],
440 param_dict['body_pose'],
441 abs_joint='right_wrist')
442
443 if self.cfg.model.check_pose:
444 # check if pose is natural (relative rotation), if not, set relative to 0 (especially for head pose)
445 # xyz: pitch(positive for looking down), yaw(positive for looking left), roll(rolling chin to left)
446 for pose_ind in [14]: # head [15-1, 20-1, 21-1]:
447 curr_pose = param_dict['body_pose'][:, pose_ind]
448 euler_pose = converter._compute_euler_from_matrix(curr_pose)
449 for i, max_angle in enumerate([20, 70, 10]):
450 euler_pose_curr = euler_pose[:, i]
451 euler_pose_curr[
452 euler_pose_curr !=
453 torch.clamp(
454 euler_pose_curr,
455 min=-max_angle*np.pi/180,
456 max=max_angle*np.pi/180)
457 ] = 0.
458 param_dict['body_pose'][:, pose_ind] = converter.batch_euler2matrix(euler_pose)
459
460 # SMPLX

Callers 1

forwardMethod · 0.95

Calls 9

convert_poseMethod · 0.95
estimate_translation_npFunction · 0.85
itemsMethod · 0.80
batch_orth_projMethod · 0.80
perspective_projectionFunction · 0.50
keysMethod · 0.45
pose_abs2relMethod · 0.45
toMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected