gauravtripathy commited on
Commit
a60b771
·
1 Parent(s): d45613e

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from PIL import Image
3
+ import torch
4
+
5
+ model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt')
6
+
7
+ # Confidence threshold
8
+ model.conf = 0.15
9
+
10
+ # NMS IoU threshold
11
+ model.iou = 0.50
12
+
13
+ imgs = '2.jpg'
14
+
15
+
16
+ def object_detection(img):
17
+
18
+ result = model(img, size=416)
19
+ result.show()
20
+
21
+ return Image.fromarray(result.imgs[0])
22
+
23
+ iface = gr.Interface(
24
+ object_detection,
25
+ gr.inputs.Image(),
26
+ "image"
27
+ )
28
+
29
+ iface.launch(
30
+ # debug=True
31
+ )
32
+
33
+
34
+ object_detection(imgs)
35
+
36
+