test_modarb_api / app.py
Ahmed007's picture
Add application file
40df25a
raw
history blame
746 Bytes
import gradio as gr
import requests
def send_to_fastapi(image, question):
url = 'https://ahmed007-modarb-api.hf.space/analyze-image/'
# Convert the image to bytes for the request
image_bytes = image.read()
files = {'file': ('image.png', image_bytes, 'image/png')}
data = {'question': question}
response = requests.post(url, files=files, data=data)
return response.json()['answer']
iface = gr.Interface(fn=send_to_fastapi,
inputs=[gr.Image(), gr.Textbox(lines=2, placeholder="Enter your question here...")],
outputs='text',
title="Image Question Answering",
description="Upload an image and ask a question about it.")
iface.launch()