-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
32 lines (22 loc) · 1.01 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
import argparse
from utils.misc import *
from train import train
from evaluate import evaluate
def main(args):
if args.mode == "train":
config = load_config_file(args.config_file_path)
train(config)
elif args.mode == "evaluate":
evaluate(args)
else:
raise Warning(f"Unrecognized mode {args.mode}!")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
sub_parsers = parser.add_subparsers(help="help for mode", dest="mode")
train_parser: argparse.ArgumentParser = sub_parsers.add_parser("train", help="train model using a configuration file")
train_parser.add_argument(
"-c", "--config-file", help="path to config file", dest="config_file_path", type=str, required=False)
evaluate_parser: argparse.ArgumentParser = sub_parsers.add_parser("evaluate", help="evaluate a model")
evaluate_parser.add_argument("-d", "--dir", help="path to model run directory", dest="run_dir")
args = parser.parse_args()
main(args)