Spaces:
Sleeping
Sleeping
Commit
·
591dc67
1
Parent(s):
5de67ef
Fix: version dependency
Browse files
app.py
CHANGED
@@ -34,7 +34,7 @@ def parse_detections(results, yolo_version):
|
|
34 |
# For YOLOv8
|
35 |
for result in results:
|
36 |
for box in result.boxes:
|
37 |
-
xmin, ymin, xmax, ymax = box.xyxy.tolist()
|
38 |
confidence = box.conf.item()
|
39 |
class_id = int(box.cls.item())
|
40 |
if confidence > 0.2:
|
@@ -47,7 +47,7 @@ def parse_detections(results, yolo_version):
|
|
47 |
# Draw bounding boxes and labels
|
48 |
def draw_detections(boxes, colors, names, img):
|
49 |
for box, color, name in zip(boxes, colors, names):
|
50 |
-
xmin, ymin, xmax, ymax = map(int, box
|
51 |
cv2.rectangle(img, (xmin, ymin), (xmax, ymax), color.tolist(), 2)
|
52 |
cv2.putText(img, name, (xmin, ymin - 5),
|
53 |
cv2.FONT_HERSHEY_SIMPLEX, 0.8, color.tolist(), 2,
|
|
|
34 |
# For YOLOv8
|
35 |
for result in results:
|
36 |
for box in result.boxes:
|
37 |
+
xmin, ymin, xmax, ymax = box[0].xyxy.tolist()
|
38 |
confidence = box.conf.item()
|
39 |
class_id = int(box.cls.item())
|
40 |
if confidence > 0.2:
|
|
|
47 |
# Draw bounding boxes and labels
|
48 |
def draw_detections(boxes, colors, names, img):
|
49 |
for box, color, name in zip(boxes, colors, names):
|
50 |
+
xmin, ymin, xmax, ymax = map(int, box)
|
51 |
cv2.rectangle(img, (xmin, ymin), (xmax, ymax), color.tolist(), 2)
|
52 |
cv2.putText(img, name, (xmin, ymin - 5),
|
53 |
cv2.FONT_HERSHEY_SIMPLEX, 0.8, color.tolist(), 2,
|