Spaces:
Sleeping
Sleeping
Add application file
Browse files- app.py +9 -2
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,10 +1,17 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
|
|
3 |
|
4 |
def send_to_fastapi(image, question):
|
5 |
url = 'https://ahmed007-modarb-api.hf.space/analyze-image/'
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
8 |
files = {'file': ('image.png', image_bytes, 'image/png')}
|
9 |
data = {'question': question}
|
10 |
response = requests.post(url, files=files, data=data)
|
|
|
1 |
+
import cv2
|
2 |
+
import numpy as np
|
3 |
import gradio as gr
|
4 |
import requests
|
5 |
+
from io import BytesIO
|
6 |
|
7 |
def send_to_fastapi(image, question):
|
8 |
url = 'https://ahmed007-modarb-api.hf.space/analyze-image/'
|
9 |
+
|
10 |
+
|
11 |
+
# Convert the numpy image to bytes
|
12 |
+
_, encoded_image = cv2.imencode('.png', image)
|
13 |
+
image_bytes = BytesIO(encoded_image.tobytes())
|
14 |
+
|
15 |
files = {'file': ('image.png', image_bytes, 'image/png')}
|
16 |
data = {'question': question}
|
17 |
response = requests.post(url, files=files, data=data)
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
opencv-python-headless
|