forked from AITRICS/Delta-XAI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappend_diff_label.py
More file actions
31 lines (25 loc) · 1.12 KB
/
Copy pathappend_diff_label.py
File metadata and controls
31 lines (25 loc) · 1.12 KB
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
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import os
from pathlib import Path
from matplotlib.font_manager import FontProperties
import pickle
import pdb
if __name__=='__main__':
data_list = [os.path.join('merged_heatmap2', x) for x in os.listdir('merged_heatmap2')]
font_path = 'scripts/Times New Roman.ttf'
times_new_roman_title = FontProperties(fname=font_path, size=30)
score_diff = pickle.load(open('heatmap_score_diff.pkl', 'rb'))
score_prev = pickle.load(open('heatmap_score_prev.pkl', 'rb'))
score_curr = pickle.load(open('heatmap_score_curr.pkl', 'rb'))
for idx, path in enumerate(data_list):
fig, ax = plt.subplots(figsize=(15, 15))
img = mpimg.imread(path)
ax.imshow(img)
ax.axis("off")
title_text = f'Previous Score: {score_prev[idx][0]:.2f} \u2192 Current Score: {score_curr[idx][0]:.2f} (Score Diff: {score_diff[idx]:.2f})'
fig.suptitle(title_text, fontproperties=times_new_roman_title, y=0.77)
plt.tight_layout(pad=0)
fig.savefig(path, dpi=300, bbox_inches="tight")
plt.close('all')
print(idx)