Spaces:
Sleeping
Sleeping
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() | |