-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeepvidv2.py
More file actions
49 lines (38 loc) · 1.24 KB
/
deepvidv2.py
File metadata and controls
49 lines (38 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
48
49
import os
import argparse
from source.utils import JsonSaver
import scripts.train as train
import scripts.inference as inference
def get_parser():
parser = argparse.ArgumentParser()
# add subparsers
subparsers = parser.add_subparsers(required=True)
subparsers = train.get_parser(subparsers)
subparsers = inference.get_parser(subparsers)
return parser
if __name__ == "__main__":
parser = get_parser()
args = parser.parse_args()
if args.mode == "train":
args = train.process_args(args)
elif args.mode == "inference":
args = inference.process_args(args)
else:
raise ValueError("Invalid mode")
# make output directory
os.makedirs(args.output_dir, exist_ok=True)
os.makedirs(os.path.join(args.output_dir, "config"), exist_ok=True)
# save config
sorted_args = dict(sorted(vars(args).items()))
path_config = os.path.join(
args.output_dir, "config", "config_{}.json".format(args.mode)
)
json_obj = JsonSaver(sorted_args)
json_obj.save_json(path_config)
# run worker
if args.mode == "train":
train.run_worker(args)
elif args.mode == "inference":
inference.run_worker(args)
else:
raise ValueError("Invalid mode")