Spaces:
Runtime error
Runtime error
Amar Gill
commited on
Commit
·
bf029b0
1
Parent(s):
13b7ff6
update app
Browse files
app.py
CHANGED
@@ -1,9 +1,31 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
|
|
|
|
3 |
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
6 |
|
7 |
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from ultralyticsplus import YOLO, render_result
|
3 |
|
4 |
+
# load model
|
5 |
+
model = YOLO("keremberke/yolov8m-hard-hat-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 = "YOLO"
|
20 |
+
description = "swag"
|
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()
|