Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,34 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
def greet(name):
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from generic import save_image_vis
|
| 3 |
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
|
| 6 |
+
def generate_viz(URL, question):
|
| 7 |
+
|
| 8 |
+
print(f"Input Image URL: {URL}")
|
| 9 |
+
print(f"Target Class: {question}")
|
| 10 |
+
|
| 11 |
+
img, html_page, answer = save_image_vis(URL, question)
|
| 12 |
+
|
| 13 |
+
return img, answer, html_page
|
| 14 |
+
|
| 15 |
+
title = "Explain LXMERT 🤯"
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
iface = gr.Interface(fn=generate_viz, inputs=[
|
| 19 |
+
gr.Text(label="Input Image URL"),
|
| 20 |
+
gr.Text(label="Input the Question "
|
| 21 |
+
],
|
| 22 |
+
outputs=[ gr.Image(label="EXplain Image"), gr.Text(label="Answer"), gr.HTML(label="Visualize Sentence Importance"),],
|
| 23 |
+
title=title,
|
| 24 |
+
allow_flagging="never",
|
| 25 |
+
cache_examples=True,
|
| 26 |
+
examples=[
|
| 27 |
+
["./lxmert/experiments/paper/COCO_val2014_000000185590/COCO_val2014_000000185590.jpg", "is the animal eating?"],
|
| 28 |
+
["./lxmert/experiments/paper/COCO_val2014_000000127510/COCO_val2014_000000127510.jpg", "did he catch the ball?"],
|
| 29 |
+
["./lxmert/experiments/paper/COCO_val2014_000000324266/COCO_val2014_000000324266.jpg", "is the tub white ?"],
|
| 30 |
+
["./lxmert/experiments/paper/COCO_val2014_000000200717/COCO_val2014_000000200717.jpg", "did the man just catch the frisbee?"],
|
| 31 |
+
],
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
iface.launch(debug=True)
|