Update app.py
Browse files
app.py
CHANGED
|
@@ -52,9 +52,10 @@ def gradcam(img_create):
|
|
| 52 |
fig,ax = plt.subplots()
|
| 53 |
x_dec.show(ctx=ax)
|
| 54 |
ax.imshow(cam_map[1].detach().cpu(), alpha=0.6, extent=(0,128,128,0), interpolation='bilinear', cmap='magma');
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
im=
|
|
|
|
| 58 |
|
| 59 |
return dict(zip(categories, map(float, probs))), im
|
| 60 |
|
|
@@ -74,6 +75,6 @@ examples=["filibe-1-1.jpg",
|
|
| 74 |
"varna-1-1.jpg"]
|
| 75 |
|
| 76 |
|
| 77 |
-
demo = gr.Interface(fn=gradcam, inputs=image, outputs=[label,
|
| 78 |
|
| 79 |
demo.launch(inline=False)
|
|
|
|
| 52 |
fig,ax = plt.subplots()
|
| 53 |
x_dec.show(ctx=ax)
|
| 54 |
ax.imshow(cam_map[1].detach().cpu(), alpha=0.6, extent=(0,128,128,0), interpolation='bilinear', cmap='magma');
|
| 55 |
+
fig.savefig("gcam.jpg")
|
| 56 |
+
im=cv2.imread("gcam.jpg",1)
|
| 57 |
+
im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
|
| 58 |
+
#im=np.fromstring(fig.canvas.tostring_rgb(), dtype=np.uint8, sep='')
|
| 59 |
|
| 60 |
return dict(zip(categories, map(float, probs))), im
|
| 61 |
|
|
|
|
| 75 |
"varna-1-1.jpg"]
|
| 76 |
|
| 77 |
|
| 78 |
+
demo = gr.Interface(fn=gradcam, inputs=image, outputs=[label, gr.inputs.Image(shape=(128,128))], examples=examples)
|
| 79 |
|
| 80 |
demo.launch(inline=False)
|