-
Notifications
You must be signed in to change notification settings - Fork 1
/
prepare.py
28 lines (23 loc) · 1005 Bytes
/
prepare.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
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '5' # silence tensorflow messages
"""Main function for model inference."""
import argparse
def parse_args():
"""Parses arguments."""
parser = argparse.ArgumentParser(description='Generate model explanations in advance.')
parser.add_argument('--target', type=str, required=True, choices=['celeba', 'mnist', 'cifar10'],
help='input data type of target model')
parser.add_argument('--xai', type=str, required=True, choices=['grad', 'gradcam', 'lrp'],
help='xai type')
parser.add_argument('--gpu', type=int, default=0,
help='gpu number for DNN training (default: 0))')
return parser.parse_args()
def main():
"""Main function."""
# Parse arguments.
args = parse_args()
os.environ["CUDA_VISIBLE_DEVICES"] = str(args.gpu)
fname = f'scripts.prepare_{args.target}_{args.xai}'
__import__(fname)
if __name__ == '__main__':
main()