MCPcopy
hub / github.com/OpenMotionLab/MotionGPT / uniform_skeleton

Function uniform_skeleton

mGPT/data/humanml/scripts/motion_process.py:13–36  ·  view source on GitHub ↗
(positions, target_offset)

Source from the content-addressed store, hash-verified

11
12# positions (batch, joint_num, 3)
13def uniform_skeleton(positions, target_offset):
14 src_skel = Skeleton(n_raw_offsets, kinematic_chain, 'cpu')
15 src_offset = src_skel.get_offsets_joints(torch.from_numpy(positions[0]))
16 src_offset = src_offset.numpy()
17 tgt_offset = target_offset.numpy()
18 # print(src_offset)
19 # print(tgt_offset)
20 '''Calculate Scale Ratio as the ratio of legs'''
21 src_leg_len = np.abs(src_offset[l_idx1]).max() + np.abs(src_offset[l_idx2]).max()
22 tgt_leg_len = np.abs(tgt_offset[l_idx1]).max() + np.abs(tgt_offset[l_idx2]).max()
23
24 scale_rt = tgt_leg_len / src_leg_len
25 # print(scale_rt)
26 src_root_pos = positions[:, 0]
27 tgt_root_pos = src_root_pos * scale_rt
28
29 '''Inverse Kinematics'''
30 quat_params = src_skel.inverse_kinematics_np(positions, face_joint_indx)
31 # print(quat_params.shape)
32
33 '''Forward Kinematics'''
34 src_skel.set_offset(target_offset)
35 new_joints = src_skel.forward_kinematics_np(quat_params, tgt_root_pos)
36 return new_joints
37
38
39def extract_features(positions, feet_thre, n_raw_offsets, kinematic_chain, face_joint_indx, fid_r, fid_l):

Callers 1

process_fileFunction · 0.85

Calls 5

get_offsets_jointsMethod · 0.95
inverse_kinematics_npMethod · 0.95
set_offsetMethod · 0.95
forward_kinematics_npMethod · 0.95
SkeletonClass · 0.85

Tested by

no test coverage detected