-
Notifications
You must be signed in to change notification settings - Fork 2
/
build_bfcnn.py
77 lines (56 loc) · 1.82 KB
/
build_bfcnn.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
r"""build a bfcnn model"""
__author__ = "Nikolas Markou"
__version__ = "1.0.0"
__license__ = "MIT"
# ---------------------------------------------------------------------
import os
import sys
import argparse
import subprocess
# ---------------------------------------------------------------------
CONFIGS_DIR = "bfcnn/configs"
CONFIGS = {
os.path.basename(file_dir).split(".")[0]:
os.path.join(CONFIGS_DIR, file_dir)
for file_dir in os.listdir(CONFIGS_DIR)
}
# ---------------------------------------------------------------------
def main(args):
# --- argument checking
if args.model is None or len(args.model) <= 0:
raise ValueError("you must select a model")
# --- set variables
model = args.model.lower()
# --- check if model in configs
if model not in CONFIGS:
raise ValueError(
"could not find model [{0}], available options [{1}]".format(
model, CONFIGS.keys()))
config = CONFIGS[model]
return \
subprocess.check_call([
sys.executable,
"-m", "bfcnn.build",
"--pipeline-config",
config,
"--output-file",
args.output_file
])
# ---------------------------------------------------------------------
if __name__ == "__main__":
# define arguments
parser = argparse.ArgumentParser()
parser.add_argument(
"--model",
default="",
dest="model",
help="model to train, options: {0}".format(list(CONFIGS.keys())))
parser.add_argument(
"--output-file",
default="model.h5",
dest="output_file",
help="output file")
# parse the arguments and pass them to main
args = parser.parse_args()
sys.exit(main(args))
# ---------------------------------------------------------------------