Spaces:
Runtime error
Runtime error
import gradio as gr | |
import requests | |
from io import BytesIO | |
url = 'http://188.166.196.227:8000/predict' | |
def inference(input_image): | |
# Convert the PIL image to bytes | |
img_bytes = BytesIO() | |
input_image.save(img_bytes, format='JPEG') | |
# Send the POST request with the image data as 'image' key | |
files = {'image': ('input.jpg', img_bytes.getvalue(), 'image/jpeg')} | |
response = requests.post(url, files=files) | |
# Check if the request was successful (status code 200) | |
if response.status_code == 200: | |
return response.json() | |
else: | |
print("POST request failed with status code:", response.status_code) | |
title = "SeeFood102" | |
description = "Gradio frontend for SeeFood102, the expansion edition of SeeFood101. Note: due to cost, I shutdown the K8S cluster backend." | |
examples = [ | |
['Screenshot 2023-05-05 085533.png'] | |
] | |
iface = gr.Interface(fn=inference, | |
inputs=gr.Image(type="pil"), | |
outputs=gr.Label(num_top_classes=5), | |
title=title, | |
description=description, | |
examples=examples, | |
analytics_enabled=False) | |
iface.launch() |