-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·77 lines (55 loc) · 2.2 KB
/
main.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
import json
import os
from analyze_data.analyze import Analyze
from preprocess_data.preprocess import preprocess_dataset
from runtime.args import get_main_args
from runtime.run import RunTime
from runtime.utils import create_empty_dir, set_warning_levels
def create_folders(args):
data_path = os.path.abspath(args.data)
with open(data_path, "r") as file:
data = json.load(file)
is_test = False
if "test-data" in data.keys():
is_test = True
results = os.path.abspath(args.results)
processed_data = os.path.abspath(args.processed_data)
dirs_to_create = [results,
os.path.join(results, "predictions"),
os.path.join(results, "predictions", "train"),
os.path.join(results, "predictions", "train", "raw"),
os.path.join(results, "predictions", "train", "postprocess"),
os.path.join(results, "predictions", "train", "postprocess", "clean_mask"),
os.path.join(results, "predictions", "train", "final"),
os.path.join(results, "models"),
os.path.join(results, "models", "best"),
os.path.join(results, "models", "last")]
labels = data["labels"]
for i in range(1, len(labels)):
dirs_to_create.append(os.path.join(results, "predictions", "train", "postprocess", str(labels[i])))
if is_test:
dirs_to_create.append(os.path.join(results, "predictions", "test"))
for folder in dirs_to_create:
create_empty_dir(folder)
create_empty_dir(processed_data)
def main(args):
set_warning_levels()
# Create file structure for MIST output
create_folders(args)
if args.exec_mode == "all":
analyze = Analyze(args)
analyze.run()
preprocess_dataset(args)
runtime = RunTime(args)
runtime.run()
elif args.exec_mode == "analyze":
analyze = Analyze(args)
analyze.run()
elif args.exec_mode == "preprocess":
preprocess_dataset(args)
elif args.exec_mode == "train":
runtime = RunTime(args)
runtime.run()
if __name__ == "__main__":
args = get_main_args()
main(args)