Spaces:
Sleeping
Sleeping
Yuxiang Wang
commited on
Commit
·
8c11be1
1
Parent(s):
c5343e6
rise
Browse files- explanations.py +6 -3
explanations.py
CHANGED
@@ -66,17 +66,20 @@ def explain(model, input_image,size=600, n_classes=171) :
|
|
66 |
explanations = []
|
67 |
for e,explainer in enumerate(explainers):
|
68 |
print(f'{e}/{len(explainers)}')
|
|
|
69 |
Y = tf.one_hot([Y], n_classes)
|
70 |
phi = np.abs(explainer(X, Y))[0]
|
71 |
-
|
72 |
if len(phi.shape) == 3:
|
73 |
phi = np.mean(phi, -1)
|
74 |
-
|
75 |
show(X[0][:,size_repetitions:2*size_repetitions,:])
|
76 |
show(phi[:,size_repetitions:2*size_repetitions], p=1, alpha=0.4)
|
77 |
-
|
78 |
plt.savefig(f'phi_{e}.png')
|
|
|
79 |
explanations.append(f'phi_{e}.png')
|
|
|
80 |
print(type(explanations))
|
81 |
print(len(explanations))
|
82 |
|
|
|
66 |
explanations = []
|
67 |
for e,explainer in enumerate(explainers):
|
68 |
print(f'{e}/{len(explainers)}')
|
69 |
+
print('1')
|
70 |
Y = tf.one_hot([Y], n_classes)
|
71 |
phi = np.abs(explainer(X, Y))[0]
|
72 |
+
print('1')
|
73 |
if len(phi.shape) == 3:
|
74 |
phi = np.mean(phi, -1)
|
75 |
+
print('1')
|
76 |
show(X[0][:,size_repetitions:2*size_repetitions,:])
|
77 |
show(phi[:,size_repetitions:2*size_repetitions], p=1, alpha=0.4)
|
78 |
+
print('1')
|
79 |
plt.savefig(f'phi_{e}.png')
|
80 |
+
print('1')
|
81 |
explanations.append(f'phi_{e}.png')
|
82 |
+
print('1')
|
83 |
print(type(explanations))
|
84 |
print(len(explanations))
|
85 |
|