-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaidio.py
52 lines (45 loc) · 1.7 KB
/
aidio.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
import argparse
import subprocess
import features
import model_manager
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Extract features from a data folder to another')
parser.add_argument('module',
help='mode can be features, models)')
features.add_cli_args(parser)
model_manager.add_cli_args(parser)
args = parser.parse_args()
module = args.module
print(args)
if module == 'features':
module = 'features.py'
features_path, raw_path, feature_name = features.parse_cli_args(args)
cmd = ['python',
module,
'--features_path', str(features_path),
'--raw_path', str(raw_path),
'--feature', str(feature_name)
]
elif module == 'model':
module = 'model_manager.py'
model_name, experiment_name, data_path, models_path, label_filename, gpus, mode = model_manager.parse_cli_args(
args)
cmd = ['python',
'-W', 'ignore', # to suppress userwarnings of librosa
module,
'--model', str(model_name),
'--experiment', str(experiment_name),
'--data_path', str(data_path),
'--model_path', str(models_path),
'--label_filename', str(label_filename),
'--gpus', str(gpus),
'--mode', str(mode),
]
else:
raise NotImplementedError
# call as subprocess for failure managing
errno = -666
while errno != 0:
print('info: calling module {}'.format(module))
errno = subprocess.call(cmd)
print('debug: cmd call ended with errno = {}'.format(errno))