-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript_infer_humanpose.py
73 lines (56 loc) · 2.63 KB
/
script_infer_humanpose.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
"""
The script facilitates a clearer and faster execution of the project.
This is the SECOND script.
You may need to edit: instrument, cuda, writevideo, parent_dir, proj_dir, start_frame_idx, end_frame_idx
4. INFER human2d key points (Run this script)
5. TRACK instrument key points [python 'script_track_key_points.py'](Next script)
"""
import os
from tools.Python_in_Shell import getPython3_command
from tools.load_summary import get_folder, get_inform
shell_python_cmd = getPython3_command()
if __name__ == '__main__':
cuda = 0 # gpu_device_id
writevideo = 0 # bool: the flag to control the generation of the videos by the inferred results
instrument = 'cello' # cello or violin
root_path = os.path.abspath(f'./data/{instrument}')
folder_names = get_folder(instrument,root_path)[25:]
#If you want to process these data in batches, you can use the following annotated code.
'''
index = -1
batch_size = 85
if (index == -1 and batch_size == 1):
folder_names = [folder_names[-1]]
elif index == -1:
folder_names = folder_names[index-batch_size+1:index] + [folder_names[-1]]
else:
folder_names = folder_names[index-batch_size+1:index+1]
'''
print(folder_names)
parent_dir = instrument
os.chdir('./human_kp_2d/')
for folder_name in folder_names:
summary, _ = get_inform(folder_name,root_path)
proj_dir = folder_name
start_frame_idx = summary['StartFrame'] # use annotated data in json file or could start from first frame
end_frame_idx = summary['EndFrame'] # use annotated data in json file or could be a bit bigger than the exact end frame
"""
INFER
2D key points on human are collected in this section.
Multi-view 2D key points will be triangulated to obtain the 3D coordinates.
"""
dirs_path = os.path.abspath(f'../data/{parent_dir}/{proj_dir}/')
print(f'FolderName:{summary["FolderName"]}')
print(f'Track:{summary["Track"]}')
print(f'start_frame_idx:{start_frame_idx}')
print(f'end_frame_idx:{end_frame_idx}')
infer_command = f'{shell_python_cmd} infer_pipeline.py ' \
f'--dirs_path {dirs_path} ' \
f'--parent_dir {parent_dir} ' \
f'--proj_dir {proj_dir} '\
f'--end_frame_idx {end_frame_idx} '\
f'--start_frame_idx {start_frame_idx} '\
f'--cuda {cuda} '\
f'--writevideo {writevideo}'
os.system(infer_command)
#break