Spaces:
Sleeping
Sleeping
Add application file
Browse files
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests
|
3 |
+
|
4 |
+
def send_to_fastapi(image, question):
|
5 |
+
url = 'http://127.0.0.1:8000/analyze-image/'
|
6 |
+
files = {'file': image}
|
7 |
+
data = {'question': question}
|
8 |
+
response = requests.post(url, files=files, data=data)
|
9 |
+
return response.json()['answer']
|
10 |
+
|
11 |
+
iface = gr.Interface(fn=send_to_fastapi,
|
12 |
+
inputs=[gr.inputs.Image(type='file'), gr.inputs.Textbox(lines=2, placeholder="Enter your question here...")],
|
13 |
+
outputs='text',
|
14 |
+
title="Image Question Answering",
|
15 |
+
description="Upload an image and ask a question about it.")
|
16 |
+
|
17 |
+
iface.launch()
|