File size: 619 Bytes
884044e
 
 
 
 
 
 
 
 
c48f318
884044e
 
 
86f7280
884044e
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)