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