Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import string
|
2 |
+
import gradio as gr
|
3 |
+
import requests
|
4 |
+
def inference_caption():
|
5 |
+
return
|
6 |
+
def inference_chat():
|
7 |
+
return "hello"
|
8 |
+
|
9 |
+
with gr.Blocks(
|
10 |
+
css="""
|
11 |
+
.message.svelte-w6rprc.svelte-w6rprc.svelte-w6rprc {font-size: 20px; margin-top: 20px}
|
12 |
+
#component-21 > div.wrap.svelte-w6rprc {height: 600px;}
|
13 |
+
"""
|
14 |
+
) as iface:
|
15 |
+
state = gr.State([])
|
16 |
+
#caption_output = state
|
17 |
+
#gr.Markdown(title)
|
18 |
+
#gr.Markdown(description)
|
19 |
+
#gr.Markdown(article)
|
20 |
+
|
21 |
+
with gr.Row():
|
22 |
+
with gr.Column(scale=1):
|
23 |
+
image_input = gr.Image(type="pil")
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
with gr.Column(scale=1.8):
|
28 |
+
|
29 |
+
with gr.Row():
|
30 |
+
with gr.Column():
|
31 |
+
caption_output = gr.Textbox(lines=1, label="VQA Output")
|
32 |
+
with gr.Column(scale=1):
|
33 |
+
chat_input = gr.Textbox(lines=1, label="VQA Input")
|
34 |
+
chat_input.submit(
|
35 |
+
inference_chat,
|
36 |
+
[
|
37 |
+
image_input,
|
38 |
+
chat_input,
|
39 |
+
],
|
40 |
+
[ caption_output],
|
41 |
+
)
|
42 |
+
|
43 |
+
with gr.Row():
|
44 |
+
clear_button = gr.Button(value="Clear", interactive=True)
|
45 |
+
clear_button.click(
|
46 |
+
lambda: ("", [], []),
|
47 |
+
[],
|
48 |
+
[chat_input, state],
|
49 |
+
queue=False,
|
50 |
+
)
|
51 |
+
|
52 |
+
submit_button = gr.Button(
|
53 |
+
value="Submit", interactive=True, variant="primary"
|
54 |
+
)
|
55 |
+
submit_button.click(
|
56 |
+
inference_chat,
|
57 |
+
[
|
58 |
+
image_input,
|
59 |
+
chat_input,
|
60 |
+
],
|
61 |
+
[caption_output],
|
62 |
+
)
|
63 |
+
|
64 |
+
|
65 |
+
image_input.change(
|
66 |
+
lambda: ("", "", []),
|
67 |
+
[],
|
68 |
+
[ caption_output, state],
|
69 |
+
queue=False,
|
70 |
+
)
|
71 |
+
|
72 |
+
# examples = gr.Examples(
|
73 |
+
# examples=examples,
|
74 |
+
# inputs=[image_input, chat_input],
|
75 |
+
# )
|
76 |
+
|
77 |
+
iface.queue(concurrency_count=1, api_open=False, max_size=10)
|
78 |
+
iface.launch(enable_queue=True)
|