MCPcopy Create free account
hub / github.com/MotrixLab/ViMoGen / collect_motion_rep_DART

Function collect_motion_rep_DART

motion_rep/retarget_motion.py:13–37  ·  view source on GitHub ↗
(smpl_params, joints)

Source from the content-addressed store, hash-verified

11
12
13def collect_motion_rep_DART(smpl_params, joints):
14 # follow DART: (https://arxiv.org/pdf/2410.05260), final motion: (seq_len, 276)
15 seq_len = smpl_params['transl'].shape[0]
16 # global_orient & angle velocity of global_orient
17 global_orient_aa = smpl_params['global_orient'].view(seq_len, 3) # (seq_len, 3)
18 rot_R = axis_angle_to_mat3x3(global_orient_aa) # (seq_len, 3, 3)
19 rot_vel = torch.matmul(rot_R[1:], rot_R[:-1].transpose(-1, -2)) # (seq_len-1, 3, 3)
20 # Use Rot6D as representation
21 rot_6D = mat3x3_to_rot6d(rot_R) # Shape: (seq_len, 6)
22 rot_vel_6D = mat3x3_to_rot6d(rot_vel) # Shape: (seq_len-1, 6)
23
24 # translation & velocity of translation
25 trans = smpl_params['transl'] # Shape: (seq_len, 3)
26 trans_vel = smpl_params['transl'][1:] - smpl_params['transl'][:-1] # Shape: (seq_len-1, 3)
27
28 # joints & velocity of joints
29 joints = joints.reshape(seq_len, -1) # Shape: (seq_len, joints_num*3)
30 joints_vel = (joints[1:] - joints[:-1]) # Shape: (seq_len-1, joints_num*3)
31
32 # body poses axis-angle -> Rot6D
33 body_poses = smpl_params['body_pose'].reshape(-1, 3) # Shape: (seq_len*(joints_num-1), 3)
34 body_poses = axis_angle_to_rot6d(body_poses).reshape(seq_len, -1) # Shape: (seq_len, (joints_num-1)*6)
35
36 motion = torch.cat([body_poses[:-1], joints[:-1], joints_vel, rot_6D[:-1], rot_vel_6D, trans[:-1], trans_vel], dim=-1)
37 return motion
38
39def motion_rep_to_SMPL(motion, recover_from_velocity=False, equal_length=False):
40 """

Callers 2

convert_hmr_to_motionFunction · 0.90
canonicalize_motionFunction · 0.85

Calls 3

axis_angle_to_mat3x3Function · 0.85
mat3x3_to_rot6dFunction · 0.85
axis_angle_to_rot6dFunction · 0.85

Tested by

no test coverage detected