Spaces:
Runtime error
Runtime error
Bence
commited on
Commit
·
48b43dc
1
Parent(s):
463620b
yolov8s
Browse files
app.py
CHANGED
|
@@ -1,4 +1,21 @@
|
|
| 1 |
-
import
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ultralyticsplus import YOLO, render_result
|
| 2 |
|
| 3 |
+
# load model
|
| 4 |
+
model = YOLO('ultralyticsplus/yolov8s')
|
| 5 |
+
|
| 6 |
+
# set model parameters
|
| 7 |
+
model.overrides['conf'] = 0.25 # NMS confidence threshold
|
| 8 |
+
model.overrides['iou'] = 0.45 # NMS IoU threshold
|
| 9 |
+
model.overrides['agnostic_nms'] = False # NMS class-agnostic
|
| 10 |
+
model.overrides['max_det'] = 1000 # maximum number of detections per image
|
| 11 |
+
|
| 12 |
+
# set image
|
| 13 |
+
image = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg'
|
| 14 |
+
|
| 15 |
+
# perform inference
|
| 16 |
+
results = model.predict(image)
|
| 17 |
+
|
| 18 |
+
# observe results
|
| 19 |
+
print(results[0].boxes)
|
| 20 |
+
render = render_result(model=model, image=image, result=results[0])
|
| 21 |
+
render.show()
|