-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
66 lines (56 loc) · 2.42 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
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
import sys
import logging
import platform
import argparse
from omegaconf import OmegaConf
def main():
# load args from user
parser = argparse.ArgumentParser(description='AutoGCN algorithm')
parser.add_argument('--mode', '-m', choices=['xai'], default='nas',
help='Select the operating mode')
parser.add_argument('--config', '-c', default='./config/config_ntu.yaml', type=str,
help='Choose the config file')
parser.add_argument('--debug', '-d', action='store_true', help='Debug mode on/off')
parser.add_argument('--node', '-n', default='./config/config_node.yaml', type=str,
help='Choose the node config file')
parser = parser.parse_args()
# Overall config
args = OmegaConf.load(parser.config)
# get mode and debug flag from parser
args.mode = parser.mode
args.debug = parser.debug
# Load Node configuration and change data paths accordingly
node = platform.node()
if node.startswith("idun"):
node = "idun"
config_node = OmegaConf.load(parser.node)
if node in config_node or any(node.startswith(n) for n in config_node):
# Update paths based on working node else leave to user definition
args.dataset_args.root_folder = config_node.get(node, {}).get('dataset_args').get('root_folder')
args.dataset_args.ntu60_path = config_node.get(node, {}).get('dataset_args').get('ntu60_path')
args.dataset_args.ntu120_path = config_node.get(node, {}).get('dataset_args').get('ntu120_path')
args.work_dir = config_node.get(node)['work_dir']
if args.cont_training:
# cont. training
cont_dir = args.cont_dir
assert cont_dir is not None
args = OmegaConf.load('{}/config.yaml'.format(cont_dir))
args.cont_training = True
args.cont_dir = cont_dir
# Choice of mode
elif parser.mode == "xai":
if args.xai_algo == "shap":
from src.xai import ShapGCN
explainer = ShapGCN(args)
explainer.start()
elif args.xai_algo == "gradcam":
from src.xai import GradCamGCN
explainer = GradCamGCN(args)
explainer.start()
else:
logging.error(f"xai_algo {args.xai_algo} not supported either choose: shap or gradcam!")
else:
logging.error("Mode: [{}] not known!".format(parser.mode))
sys.exit()
if __name__ == '__main__':
main()