yolo5demo / app.py
guiwitz's picture
fix ims
86f7280
raw
history blame
619 Bytes
import gradio as gr
import torch
import torchvision
import numpy as np
from PIL import Image
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True)
def inference(im):
results = model(im)
results.render() # updates results.imgs with boxes and labels
return Image.fromarray(results.ims[0])
inputs = gr.inputs.Image(type='pil', label="Original Image")
outputs = gr.outputs.Image(type="pil", label="Output Image")
title = "Yolo demo"
description = "Demo of Yolo for EAAI"
gr.Interface(inference, inputs, outputs, title=title, description=description).launch(enable_queue=True)