Spaces:
Running
Running
File size: 607 Bytes
98d351c |
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 |
from gradio_client import Client, handle_file
from PIL import Image
import matplotlib.pyplot as plt
# Parameters
Server_URL = "http://127.0.0.1:7860/"
Image_URL = 'http://images.cocodataset.org/val2017/000000039769.jpg'
# URL to client server (e.g. local server, docker container or AWS ECS)
client = Client(Server_URL)
# Call to API
result = client.predict(
image=handle_file(Image_URL),
api_name="/predict"
)
# Result is an image.webp file
print(result)
# Display image via matplotlib
img = Image.open(result).convert("RGB")
plt.figure(figsize=(8, 5))
plt.imshow(img)
plt.axis('off')
plt.show()
|