Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,29 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
from PIL import Image
|
| 4 |
+
from io import BytesIO
|
| 5 |
|
| 6 |
+
# Function to upload the image to the Hugging Face model
|
| 7 |
+
def upload_image(image):
|
| 8 |
+
# Send the image to Hugging Face
|
| 9 |
+
response = requests.post(
|
| 10 |
+
"https://api.deepai.org/api/analyze-image",
|
| 11 |
+
files={"image": image},
|
| 12 |
+
headers={"api-key": "YOUR_HUGGING_FACE_API_KEY"}
|
| 13 |
+
)
|
| 14 |
|
| 15 |
+
# Parse the response and get the result
|
| 16 |
+
result = response.json()
|
| 17 |
+
prediction = result.get("output", "Error")
|
| 18 |
+
|
| 19 |
+
return prediction
|
| 20 |
+
|
| 21 |
+
# Gradio interface
|
| 22 |
+
iface = gr.Interface(
|
| 23 |
+
fn=upload_image,
|
| 24 |
+
inputs=gr.Image(type="pil", label="Upload Image"),
|
| 25 |
+
outputs="text"
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
# Launch the Gradio app
|
| 29 |
+
iface.launch()
|