File size: 895 Bytes
2d5fdd1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from scipy.spatial.transform import Rotation as R
import numpy as np

def rot_mats_to_eulers(predicted_mats):
    ident = np.eye(3, dtype=np.float32)
    angle_axes = np.zeros((predicted_mats.shape[0],72))
    for i,joints in enumerate(predicted_mats):
        joints = joints[0]
        trans = joints[216:]
        joints = joints[:216].reshape(-1,9)
        new_thing = np.zeros(72)
        # new_thing[69:] = trans
        for j,mat in enumerate(joints):
            mat = mat.reshape(3,3) + ident
            rot = R.from_matrix(mat)
            rot = rot.as_rotvec()
            new_thing[j*3:(j+1)*3] = rot
        angle_axes[i] = new_thing

    smpl_thing = {'smpl_loss':1.8,'smpl_poses':angle_axes,'smpl_trans':predicted_mats[:,0,216:], 'smpl_scaling': np.array([95])}
    # pickle.dump(smpl_thing, open("analysis/aistplusplus_api/last.generated.test.pkl", "wb"))
    return smpl_thing