njanakiev commited on
Commit
3a071fe
1 Parent(s): 23b111a

Update app.py

Browse files
Files changed (1) hide show
  1. 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
- if __name__ == '__main__':
34
- interface = gr.Interface(
35
- fn=grad_cam_fn,
36
- inputs=[
37
- gr.inputs.Textbox(
38
- label="Target Text",
39
- lines=1),
40
- gr.inputs.Image(
41
- label='Input Image',
42
- image_mode="RGB",
43
- type='pil',
44
- shape=(512, 512)),
45
- gr.inputs.Dropdown(
46
- ["layer4", "layer3", "layer2", "layer1"],
47
- default="layer4",
48
- label="Saliency Layer")
49
- ],
50
- outputs=gr.outputs.Image(
51
- type="pil",
52
- label="Attention Map"),
53
- examples=[
54
- ['a cat lying on the floor', 'assets/cat_dog.jpg', 'layer4'],
55
- ['a dog sitting', 'assets/cat_dog.jpg', 'layer4']
56
- ],
57
- description="OpenAI CLIP Grad CAM")
58
- interface.launch(
59
- server_name='0.0.0.0',
60
- server_port=7861,
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)