-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSmplObject.py
126 lines (97 loc) · 2.4 KB
/
SmplObject.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import numpy as np
import glob
import pickle
import os
from typing import Dict
from typing import Tuple
from PathFilter import PathFilter
class SmplObjects(object):
joints = ["m_avg_Pelvis"
,"m_avg_L_Hip"
,"m_avg_R_Hip"
,"m_avg_Spine1"
,"m_avg_L_Knee"
,"m_avg_R_Knee"
,"m_avg_Spine2"
,"m_avg_L_Ankle"
,"m_avg_R_Ankle"
,"m_avg_Spine3"
,"m_avg_L_Foot"
,"m_avg_R_Foot"
,"m_avg_Neck"
,"m_avg_L_Collar"
,"m_avg_R_Collar"
,"m_avg_Head"
,"m_avg_L_Shoulder"
,"m_avg_R_Shoulder"
,"m_avg_L_Elbow"
,"m_avg_R_Elbow"
,"m_avg_L_Wrist"
,"m_avg_R_Wrist"
,"m_avg_L_Hand"
,"m_avg_R_Hand"]
smplh_joints = [
"m_avg_Pelvis"
,"m_avg_L_Hip"
,"m_avg_R_Hip"
,"m_avg_Spine1"
,"m_avg_L_Knee"
,"m_avg_R_Knee"
,"m_avg_Spine2"
,"m_avg_L_Ankle"
,"m_avg_R_Ankle"
,"m_avg_Spine3"
,"m_avg_L_Foot"
,"m_avg_R_Foot"
,"m_avg_Neck"
,"m_avg_L_Collar"
,"m_avg_R_Collar"
,"m_avg_Head"
,"m_avg_L_Shoulder"
,"m_avg_R_Shoulder"
,"m_avg_L_Elbow"
,"m_avg_R_Elbow"
,"m_avg_L_Wrist"
,"m_avg_R_Wrist"
]
kll_joints = ["m_avg_Pelvis" # 卡路里老师
,"LeftUpLeg"
,"RightUpLeg"
,"Spine"
,"LeftLeg"
,"RightLeg"
,"Spine1"
,"LeftFoot"
,"RightFoot"
,"Spine2"
,"LeftToeBase"
,"RightToeBase"
,"Neck"
,"LeftShoulder"
,"RightShoulder"
,"Head"
,"LeftArm"
,"RightArm"
,"LeftForeArm"
,"RightForeArm"
,"LeftHand"
,"RightHand"
,"LeftFinger"
,"RightFinger"]
def __init__(self, read_path):
self.files = {}
# For AIST naming convention
#paths = PathFilter.filter(read_path, dance_genres=["gBR"], dance_types=["sBM"], music_IDs=["0"])
paths = PathFilter.filter(read_path, dance_genres=None, dance_types=None, music_IDs=None)
for path in paths:
filename = path.split("/")[-1]
with open(path, "rb") as fp:
data = pickle.load(fp)
self.files[filename] = {"smpl_poses":data["smpl_poses"],
"smpl_trans":data["smpl_trans"]}
self.keys = [key for key in self.files.keys()]
def __len__(self):
return len(self.keys)
def __getitem__(self, idx:int) -> Tuple[str, Dict]:
key = self.keys[idx]
return key, self.files[key]