Update app.py
Browse files- gradcam/app.py +28 -29
gradcam/app.py
CHANGED
@@ -30,32 +30,31 @@ def grad_cam_fn(text, img, saliency_layer):
|
|
30 |
return attn_map
|
31 |
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
inputs
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
share=False)
|
|
|
30 |
return attn_map
|
31 |
|
32 |
|
33 |
+
interface = gr.Interface(
|
34 |
+
fn=grad_cam_fn,
|
35 |
+
inputs=[
|
36 |
+
gr.inputs.Textbox(
|
37 |
+
label="Target Text",
|
38 |
+
lines=1),
|
39 |
+
gr.inputs.Image(
|
40 |
+
label='Input Image',
|
41 |
+
image_mode="RGB",
|
42 |
+
type='pil',
|
43 |
+
shape=(512, 512)),
|
44 |
+
gr.inputs.Dropdown(
|
45 |
+
["layer4", "layer3", "layer2", "layer1"],
|
46 |
+
default="layer4",
|
47 |
+
label="Saliency Layer")
|
48 |
+
],
|
49 |
+
outputs=gr.outputs.Image(
|
50 |
+
type="pil",
|
51 |
+
label="Attention Map"),
|
52 |
+
examples=[
|
53 |
+
['a cat lying on the floor', 'assets/cat_dog.jpg', 'layer4'],
|
54 |
+
['a dog sitting', 'assets/cat_dog.jpg', 'layer4']
|
55 |
+
],
|
56 |
+
description="OpenAI CLIP Grad CAM")
|
57 |
+
interface.launch(
|
58 |
+
server_name='0.0.0.0',
|
59 |
+
server_port=7861,
|
60 |
+
share=False)
|
|