File size: 486 Bytes
a60b771
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
29
30
31
32
33
34
35
36
37
import gradio as gr
from PIL import Image
import torch

model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt')

# Confidence threshold
model.conf = 0.15

# NMS IoU threshold
model.iou = 0.50

imgs = '2.jpg'


def object_detection(img):

  result = model(img, size=416)
  result.show()

  return Image.fromarray(result.imgs[0])

iface = gr.Interface(
    object_detection,
    gr.inputs.Image(),
    "image"
)

iface.launch(
    # debug=True
)


object_detection(imgs)