Ahmed007 commited on
Commit
40df25a
·
1 Parent(s): b6454cf

Add application file

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -2,14 +2,16 @@ 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.png', image, 'image/png')}
 
 
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(type='file'), gr.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.")
 
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.")