File size: 623 Bytes
339d133
 
 
 
 
03a517d
339d133
 
03a517d
 
 
 
 
 
339d133
 
f1fe0df
339d133
03a517d
f1fe0df
2642a92
f1fe0df
 
 
 
 
 
 
f312c0e
339d133
 
f1fe0df
339d133
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
import torch
import cv2
import numpy as np
import gradio as gr


model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True)


model.conf = 0.25  
model.iou = 0.45  
model.agnostic = False  
model.multi_label = False  
model.max_det = 1000


img = gr.inputs.Image(shape=(192, 192))


results = model(img, size=640)

predictions = results.pred[0]
boxes = predictions[:, :4] # x1, y1, x2, y2
scores = predictions[:, 4]
categories = predictions[:, 5]
annotated_image = np.squeeze(results.render())

outputs= plt.imshow(annotated_image)



intf = gr.Interface(inputs=img, outputs=outputs)
intf.launch(inline=False)