Spaces:
Runtime error
Runtime error
using figure for activations now
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
from matplotlib import cm
|
2 |
import matplotlib.pyplot as plt
|
3 |
-
|
4 |
|
5 |
import numpy as np
|
6 |
|
@@ -167,9 +167,35 @@ def predict_and_analyze(model_name, num_channels, dim, image):
|
|
167 |
activation_1 = normalize_array(activation_1)
|
168 |
activation_2 = normalize_array(activation_2)
|
169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
print("Sending to Hugging Face")
|
171 |
|
172 |
-
return output, input_image,
|
173 |
|
174 |
|
175 |
demo = gr.Interface(
|
@@ -189,8 +215,11 @@ demo = gr.Interface(
|
|
189 |
gr.File(label="Input Data", show_label=True)],
|
190 |
outputs=[gr.Textbox(lines=1, label="Prediction", show_label=True),
|
191 |
gr.Image(label="Input Image", show_label=True),
|
192 |
-
|
193 |
-
|
|
|
|
|
|
|
194 |
title="Kinematic Planet Detector"
|
195 |
)
|
196 |
demo.launch()
|
|
|
1 |
from matplotlib import cm
|
2 |
import matplotlib.pyplot as plt
|
3 |
+
from mpl_toolkits.axes_grid1 import make_axes_locatable
|
4 |
|
5 |
import numpy as np
|
6 |
|
|
|
167 |
activation_1 = normalize_array(activation_1)
|
168 |
activation_2 = normalize_array(activation_2)
|
169 |
|
170 |
+
print("Plotting")
|
171 |
+
|
172 |
+
origin = 'lower'
|
173 |
+
|
174 |
+
plt.rcParams['xtick.labelsize'] = ticks
|
175 |
+
plt.rcParams['ytick.labelsize'] = ticks
|
176 |
+
|
177 |
+
fig, axs = plt.subplots(nrows=1, ncols=2, figsize=(19, 8))
|
178 |
+
|
179 |
+
ax1, ax2 = axs[0], axs[1]
|
180 |
+
|
181 |
+
im1 = ax1.imshow(activation_1, cmap=cmap, #vmin=0, vmax=1,
|
182 |
+
origin=origin)
|
183 |
+
im2 = ax2.imshow(activation_2, cmap=cmap, #vmin=0, vmax=1,
|
184 |
+
origin=origin)
|
185 |
+
|
186 |
+
ims = [im1, im2]
|
187 |
+
|
188 |
+
for (i, ax) in enumerate(axs):
|
189 |
+
divider = make_axes_locatable(ax)
|
190 |
+
cax = divider.append_axes('right', size='5%', pad=0.05)
|
191 |
+
fig.colorbar(ims[i], cax=cax, orientation='vertical')
|
192 |
+
|
193 |
+
ax1.set_title('First Activation', fontsize=titles)
|
194 |
+
ax2.set_title('Second Activation', fontsize=titles)
|
195 |
+
|
196 |
print("Sending to Hugging Face")
|
197 |
|
198 |
+
return output, input_image, fig
|
199 |
|
200 |
|
201 |
demo = gr.Interface(
|
|
|
215 |
gr.File(label="Input Data", show_label=True)],
|
216 |
outputs=[gr.Textbox(lines=1, label="Prediction", show_label=True),
|
217 |
gr.Image(label="Input Image", show_label=True),
|
218 |
+
# gr.Image(label="Activation 1", show_label=True),
|
219 |
+
# gr.Image(label="Actication 2", show_label=True)],
|
220 |
+
gr.Plot(label="Activations", show_label=True)
|
221 |
+
# gr.Plot(label="Actication 2", show_label=True)],
|
222 |
+
],
|
223 |
title="Kinematic Planet Detector"
|
224 |
)
|
225 |
demo.launch()
|