Spaces:
Runtime error
Runtime error
Commit
•
faf3e43
1
Parent(s):
49c889e
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
def greet(name):
|
4 |
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
|
|
7 |
iface.launch()
|
|
|
1 |
+
from ultralyticsplus import YOLO, render_result
|
2 |
+
|
3 |
+
# set image
|
4 |
+
image = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg'
|
5 |
+
|
6 |
+
|
7 |
+
def PPE(params):
|
8 |
+
# load model
|
9 |
+
model = YOLO('keremberke/yolov8m-protective-equipment-detection')
|
10 |
+
|
11 |
+
# set model parameters
|
12 |
+
model.overrides['conf'] = 0.25 # NMS confidence threshold
|
13 |
+
model.overrides['iou'] = 0.45 # NMS IoU threshold
|
14 |
+
model.overrides['agnostic_nms'] = False # NMS class-agnostic
|
15 |
+
model.overrides['max_det'] = 1000 # maximum number of detections per image
|
16 |
+
|
17 |
+
|
18 |
+
|
19 |
+
# perform inference
|
20 |
+
results = model.predict(image)
|
21 |
+
|
22 |
+
# observe results
|
23 |
+
print(results[0].boxes)
|
24 |
+
render = render_result(model=model, image=image, result=results[0])
|
25 |
+
render.show()
|
26 |
+
|
27 |
+
|
28 |
import gradio as gr
|
29 |
|
30 |
def greet(name):
|
31 |
return "Hello " + name + "!!"
|
32 |
|
33 |
+
|
34 |
+
iface = gr.Interface(fn=PPE, inputs=image, outputs=PPE())
|
35 |
iface.launch()
|