Spaces:
Runtime error
Runtime error
chore: attention only plot
Browse files
app.py
CHANGED
|
@@ -43,21 +43,18 @@ def plot_attention(image):
|
|
| 43 |
index = 0
|
| 44 |
selected_image = image[index]
|
| 45 |
selected_weight = test_viz_weights[index]
|
| 46 |
-
|
| 47 |
-
fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(10, 5))
|
| 48 |
-
ax[0].imshow(selected_image)
|
| 49 |
-
ax[0].set_title(f"Original")
|
| 50 |
-
ax[0].axis("off")
|
| 51 |
|
| 52 |
-
img =
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
| 57 |
plt.axis("off")
|
| 58 |
return plt
|
| 59 |
|
| 60 |
iface = gr.Interface(
|
| 61 |
fn=plot_attention,
|
| 62 |
inputs=[gr.inputs.Image(label="Input Image")],
|
| 63 |
-
outputs="
|
|
|
|
| 43 |
index = 0
|
| 44 |
selected_image = image[index]
|
| 45 |
selected_weight = test_viz_weights[index]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
+
img = plt.imshow(selected_image)
|
| 48 |
+
plt.imshow(
|
| 49 |
+
selected_weight,
|
| 50 |
+
cmap="inferno",
|
| 51 |
+
alpha=0.6,
|
| 52 |
+
extent=img.get_extent()
|
| 53 |
+
)
|
| 54 |
plt.axis("off")
|
| 55 |
return plt
|
| 56 |
|
| 57 |
iface = gr.Interface(
|
| 58 |
fn=plot_attention,
|
| 59 |
inputs=[gr.inputs.Image(label="Input Image")],
|
| 60 |
+
outputs="Attention Map").launch()
|