Spaces:
Runtime error
Runtime error
File size: 594 Bytes
5604609 95017f1 5604609 95017f1 5604609 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import gradio as gr
from PIL import Image
import numpy as np
from ultralytics import YOLO
model = YOLO('./best.pt')
def yolo(im, size=512):
g = (size / max(im.size)) # gain
im = im.resize((int(x * g) for x in im.size), Image.ANTIALIAS) # resize
results = model(im) # inference
results.render() # updates results.imgs with boxes and labels
return Image.fromarray(results.ims[0])
gr.Interface(fn=yolo,
inputs=gr.inputs.Image(type = "pil", label = "Original Image"),
outputs=gr.outputs.Image(type = "pil", label = "Output Image")).launch()
|