File size: 961 Bytes
0d2dd1f
0e3225c
0d2dd1f
4ebcacd
 
0e3225c
11990fc
 
 
b34ea79
8851b61
f94a07c
a68c8de
 
f94a07c
11990fc
 
 
 
 
 
 
 
 
 
8851b61
2246470
 
11990fc
b34ea79
 
8851b61
b34ea79
 
11990fc
2246470
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#app.py

import gradio as gr
from gradio_client import Client

client = Client("https://adept-fuyu-8b-demo.hf.space/--replicas/9kcqv/")

filepath = "https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png"
question = "what color is the bus?"

def vqa(image:str, prompt:str):
    result = client.predict(image,prompt,fn_index=3)
    print("result: "+result)
    print("result lstrip"+result.lstrip())
    return result

css = """
  #mkd {
    height: 500px; 
    overflow: auto; 
    border: 1px solid #ccc; 
  }
"""

with gr.Blocks(css=css) as demo:
    image_input = gr.Image(label="Upload your Image", type="str")
    text_input = gr.Textbox(label="Ask a Question")
    vqa_output = gr.Textbox(label="Output")
    vqa_btn = gr.Button("Answer Visual Question")
    vqa_btn.click(
            fn=vqa,
            inputs = [image_input,text_input],
            outputs = vqa_output
        )

if __name__ == "__main__":
    demo.launch()