-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
47 lines (34 loc) · 1.24 KB
/
main.py
File metadata and controls
47 lines (34 loc) · 1.24 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
import os
import argparse
from src.app.app import App
from src.utils.utils import check_mozart_spelling
TIMESTEP = 0.25
SEQUENCE_LEN = 100
def arg_parser():
parser = argparse.ArgumentParser(
description='Train a Bi-LSTM Attention LSTM neural network')
required = parser.add_argument_group('required arguments')
optional = parser.add_argument_group('optional arguments')
required.add_argument('-d', '--data', dest='datapath',
type=dir_path, required=True)
required.add_argument('-c', '--composers', dest='composers',
nargs='+', type=str, required=True)
args = parser.parse_args()
composers_list = list(map(str.lower, args.composers))
check_mozart_spelling(composers_list)
if os.path.isabs(args.datapath):
dataset_path = args.datapath
else:
dataset_path = os.path.abspath(args.datapath)
return composers_list, dataset_path
def dir_path(string):
if os.path.isdir(string):
return string
else:
raise NotADirectoryError(string)
def main(path, composers_list):
app = App(composers_list, path)
app.run()
if __name__ == '__main__':
composers, data_path = arg_parser()
main(data_path, composers_list=composers)