Spaces:
Sleeping
Sleeping
Add application file
Browse files
app.py
CHANGED
@@ -2,14 +2,16 @@ import gradio as gr
|
|
2 |
import requests
|
3 |
|
4 |
def send_to_fastapi(image, question):
|
5 |
-
url = '
|
6 |
-
|
|
|
|
|
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.Image(
|
13 |
outputs='text',
|
14 |
title="Image Question Answering",
|
15 |
description="Upload an image and ask a question about it.")
|
|
|
2 |
import requests
|
3 |
|
4 |
def send_to_fastapi(image, question):
|
5 |
+
url = 'https://ahmed007-modarb-api.hf.space/analyze-image/'
|
6 |
+
# Convert the image to bytes for the request
|
7 |
+
image_bytes = image.read()
|
8 |
+
files = {'file': ('image.png', image_bytes, 'image/png')}
|
9 |
data = {'question': question}
|
10 |
response = requests.post(url, files=files, data=data)
|
11 |
return response.json()['answer']
|
12 |
|
13 |
iface = gr.Interface(fn=send_to_fastapi,
|
14 |
+
inputs=[gr.Image(), gr.Textbox(lines=2, placeholder="Enter your question here...")],
|
15 |
outputs='text',
|
16 |
title="Image Question Answering",
|
17 |
description="Upload an image and ask a question about it.")
|