forked from gyshgx868/graph-ter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_classification.py
39 lines (32 loc) · 1.12 KB
/
main_classification.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
import yaml
from graph_ter_cls.runner import BackboneRunner
from graph_ter_cls.runner import ClassifierRunner
from graph_ter_cls.runner import EvaluationRunner
# from graph_ter_cls.runner import SVMClassifierRunner
from graph_ter_cls.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 == 'svm':
# runner = SVMClassifierRunner(args)
elif args.phase == 'test':
runner = EvaluationRunner(args)
else:
raise ValueError('Unknown phase.')
runner.run()
if __name__ == '__main__':
main()