-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathSmplObject.py
61 lines (49 loc) · 1.35 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
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 = ["Pelvis"
,"L_Hip"
,"R_Hip"
,"Spine1"
,"L_Knee"
,"R_Knee"
,"Spine2"
,"L_Ankle"
,"R_Ankle"
,"Spine3"
,"L_Foot"
,"R_Foot"
,"Neck"
,"L_Collar"
,"R_Collar"
,"Head"
,"L_Shoulder"
,"R_Shoulder"
,"L_Elbow"
,"R_Elbow"
,"L_Wrist"
,"R_Wrist"
,"L_Hand"
,"R_Hand"]
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"] / (data["smpl_scaling"][0]*100)}
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]