MCPcopy Create free account
hub / github.com/M-Nauta/ProtoTree / get_local_expl_args

Function get_local_expl_args

main_explain_local.py:12–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10import os
11
12def get_local_expl_args() -> argparse.Namespace:
13
14 parser = argparse.ArgumentParser('Explain a prediction')
15 parser.add_argument('--prototree',
16 type=str,
17 help='Directory to trained ProtoTree')
18 parser.add_argument('--log_dir',
19 type=str,
20 default='./runs/run_prototree',
21 help='The directory in which results should be logged. Should be same log_dir as loaded ProtoTree')
22 parser.add_argument('--dataset',
23 type=str,
24 default='CUB-200-2011',
25 help='Data set on which the ProtoTree was trained')
26 parser.add_argument('--sample_dir',
27 type=str,
28 help='Directory to image to be explained, or to a folder containing multiple test images')
29 parser.add_argument('--results_dir',
30 type=str,
31 default='local_explanations',
32 help='Directory where local explanations will be saved')
33 parser.add_argument('--disable_cuda',
34 action='store_true',
35 help='Flag that disables GPU usage if set')
36 parser.add_argument('--image_size',
37 type=int,
38 default=224,
39 help='Resize images to this size')
40 parser.add_argument('--dir_for_saving_images',
41 type=str,
42 default='upsampling_results',
43 help='Directoy for saving the prototypes, patches and heatmaps')
44 parser.add_argument('--upsample_threshold',
45 type=float,
46 default=0.98,
47 help='Threshold (between 0 and 1) for visualizing the nearest patch of an image after upsampling. The higher this threshold, the larger the patches.')
48 args = parser.parse_args()
49 return args
50
51def explain_local(args):
52 if not args.disable_cuda and torch.cuda.is_available():

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected