Amar Gill commited on
Commit
f5b4485
1 Parent(s): 0d417cc

add app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from ultralyticsplus import YOLO, render_result
3
+
4
+ # load model
5
+ model = YOLO("keremberke/yolov8m-protective-equipment-detection")
6
+
7
+ # set model parameters
8
+ model.overrides["conf"] = 0.25 # NMS confidence threshold
9
+ model.overrides["iou"] = 0.45 # NMS IoU threshold
10
+ model.overrides["agnostic_nms"] = False # NMS class-agnostic
11
+ model.overrides["max_det"] = 1000 # maximum number of detections per image
12
+
13
+
14
+ def get_result(img):
15
+ results = model.predict(img)
16
+ return render_result(model=model, image=img, result=results[0])
17
+
18
+
19
+ title = "Personal Protective Equipment Detector"
20
+ description = "Upload an image to identify who is wearing a PPE and who is not."
21
+ examples = ["https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg"]
22
+
23
+ iface = gr.Interface(
24
+ title=title,
25
+ description=description,
26
+ examples=examples,
27
+ fn=get_result,
28
+ inputs=gr.components.Image(shape=(512, 512)),
29
+ outputs=gr.components.Image(shape=(512, 512)),
30
+ )
31
+ iface.launch()