forked from gyshgx868/graph-ter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_segmentation.py
36 lines (29 loc) · 1012 Bytes
/
main_segmentation.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
import yaml
from graph_ter_seg.runner import BackboneRunner
from graph_ter_seg.runner import ClassifierRunner
from graph_ter_seg.runner import EvaluationRunner
from graph_ter_seg.tools.configuration import get_parser
def main():
parser = get_parser()
args = parser.parse_args()
if args.config is not None:
with open(args.config, 'r') as f:
default_arg = yaml.load(f, Loader=yaml.FullLoader)
key = vars(args).keys()
for k in default_arg.keys():
if k not in key:
print('WRONG ARG: {}'.format(k))
assert (k in key)
parser.set_defaults(**default_arg)
args = parser.parse_args()
if args.phase == 'backbone':
runner = BackboneRunner(args)
elif args.phase == 'classifier':
runner = ClassifierRunner(args)
elif args.phase == 'test':
runner = EvaluationRunner(args)
else:
raise ValueError('Unknown phase.')
runner.run()
if __name__ == '__main__':
main()