Create new file
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import torch
|
3 |
+
import torchvision
|
4 |
+
import numpy as np
|
5 |
+
from PIL import Image
|
6 |
+
|
7 |
+
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True)
|
8 |
+
|
9 |
+
def inference(im):
|
10 |
+
results = model(imgs)
|
11 |
+
|
12 |
+
results.render() # updates results.imgs with boxes and labels
|
13 |
+
|
14 |
+
return Image.fromarray(results.imgs[0])
|
15 |
+
|
16 |
+
|
17 |
+
inputs = gr.inputs.Image(type='pil', label="Original Image")
|
18 |
+
outputs = gr.outputs.Image(type="pil", label="Output Image")
|
19 |
+
|
20 |
+
title = "Yolo demo"
|
21 |
+
description = "Demo of Yolo for EAAI"
|
22 |
+
|
23 |
+
gr.Interface(inference, inputs, outputs, title=title, description=description).launch(enable_queue=True)
|