MCPcopy Create free account
hub / github.com/CSAILVision/gandissect / run_command

Function run_command

netdissect/aceplotablate.py:25–51  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

23 run_command(args)
24
25def run_command(args):
26 fig = Figure(figsize=(4.5,3.5))
27 FigureCanvas(fig)
28 ax = fig.add_subplot(111)
29 for metric in [args.metric, 'iou']:
30 jsonname = os.path.join(args.outdir, args.layer, 'fullablation',
31 '%s-%s.json' % (args.classname, metric))
32 with open(jsonname) as f:
33 summary = json.load(f)
34 baseline = summary['baseline']
35 effects = summary['ablation_effects'][:26]
36 norm_effects = [0] + [1.0 - e / baseline for e in effects]
37 ax.plot(norm_effects, label=
38 'Units by ACE' if 'ace' in metric else 'Top units by IoU')
39 ax.set_title('Effect of ablating units for %s' % (args.classname))
40 ax.grid(True)
41 ax.legend()
42 ax.set_ylabel('Portion of %s pixels removed' % args.classname)
43 ax.set_xlabel('Number of units ablated')
44 ax.set_ylim(0, 1.0)
45 ax.set_xlim(0, 25)
46 fig.tight_layout()
47 dirname = os.path.join(args.outdir, args.layer, 'fullablation')
48 fig.savefig(os.path.join(dirname, 'effect-%s-%s.png' %
49 (args.classname, args.metric)))
50 fig.savefig(os.path.join(dirname, 'effect-%s-%s.pdf' %
51 (args.classname, args.metric)))
52
53if __name__ == '__main__':
54 main()

Callers 1

mainFunction · 0.70

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected