-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommandSystem.py
99 lines (61 loc) · 2.34 KB
/
commandSystem.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
# Standard library imports
import os
# Third party imports
# Local imports
#
# To choose just one option
def change_unique_option_state(chosen, ans):
chosen = {k:False for k, _ in chosen.items()}
chosen[ans] = True
return chosen
# To choose just multiple option
def change_options_state(chosen, ans):
if chosen[ans]:
chosen[ans] = False
else:
chosen[ans] = True
return chosen
def get_selected_option_names(options,chosen):
return [name for name, isChosed in zip(options, chosen.values()) if isChosed]
#print in console the options
def show_options(options, name):
print("##################################")
print(f"Choose {name}: (by number)\n")
for pos, opt in enumerate(options):
print(f"{pos+1}) {opt}")
# To select wich dataset are in "datasets" folders
def select_datasets():
options = os.listdir("./datasets")
# delete options that are not dataset folders
options = [opt for opt in options if len(opt.split('.'))==1]
# dictionary of selected options
chosen = {str(pos+1):False for pos in range(len(options))}
while(True):
show_options(options, 'datasets')
print(f"\n{len(options)+1}) continue\n")
chosen_names = get_selected_option_names(options,chosen)
print("Selected:",*chosen_names)
ans = input("write an option: ")
if ans == str(len(options)+1):
return chosen_names
if ans not in chosen.keys():
continue
chosen = change_options_state(chosen, ans)
# To select the desired keypoint stimator
def select_keypoint_estimator():
options = os.listdir("./keypointEstimators")
# delete options that are not .py files
options = [opt.split('_')[0] for opt in options if opt.split('.')[-1]=='py']
# dictionary of selected options
chosen = {str(pos+1):False for pos in range(len(options))}
while(True):
show_options(options, 'keypoint estimators')
print(f'\n{len(options)+1}) continue\n')
chosen_names = get_selected_option_names(options,chosen)
print("Selected:",*chosen_names)
ans = input("write an option: ")
if ans == str(len(options)+1):
return chosen_names
if ans not in chosen.keys():
continue
chosen = change_unique_option_state(chosen, ans)