-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathkitml_text_preprocess.py
More file actions
66 lines (49 loc) · 1.88 KB
/
kitml_text_preprocess.py
File metadata and controls
66 lines (49 loc) · 1.88 KB
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
import os
import json
from tools.jtools import write_json
def fix_paths_kitml(amass_path: str, kitml_process_folder: str):
# input
json_path = os.path.join(kitml_process_folder, 'kitml_amass_path.json')
# outputs
corres_json_path = os.path.join(kitml_process_folder, 'amass-path2kitml.json')
bad_amass_path = os.path.join(kitml_process_folder, 'kitml_not_found_amass.json')
with open(json_path) as ff:
dico = json.load(ff)
nseq = len(dico)
print(f"There are {nseq} sequences")
count_bad = 0
not_found_in_amass = {}
def get_path_id(x, y):
path = y["path"]
identifier = y["identifier"]
try_order = {
"kit": ["KIT", "CMU", "EKUT"],
"cmu": ["CMU", "EKUT", "KIT"]
}
sub_folders = try_order[identifier]
for sub_folder in sub_folders:
path_id = os.path.join(sub_folder, path)
smpl_datapath = os.path.join(amass_path, path_id)
if os.path.exists(smpl_datapath):
return path_id
nonlocal count_bad
count_bad += 1
# More probable missing one
path_id = os.path.join(sub_folders[0], path)
not_found_in_amass[x] = path_id
return None
paths = {
x: z for x, y in dico.items() if (z := get_path_id(x, y))
}
print(f"There are {count_bad} sequences not found in AMASS")
tot_path = len(paths)
print(f"There are {tot_path} sequences found in AMASS")
print()
write_json(paths, corres_json_path)
print(f"Saving correspondances (keyid -> AMASS) into {corres_json_path}")
write_json(not_found_in_amass, bad_amass_path)
print(f"Saving bad correspondances (missing motions in AMASS) into {bad_amass_path}")
if __name__ == "__main__":
amass_path = "datasets/AMASS/"
kitml_process_folder = "kitml_process"
fix_paths_kitml(amass_path, kitml_process_folder)