From d755bca7c80899325a5e529c6618e95172ca8a96 Mon Sep 17 00:00:00 2001 From: Christoforos Aristeidou Date: Mon, 12 Aug 2024 15:27:04 +0300 Subject: [PATCH] added check and support for SAM ultralytics results --- supervision/detection/core.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/supervision/detection/core.py b/supervision/detection/core.py index 89a526d6..5fda4ab6 100644 --- a/supervision/detection/core.py +++ b/supervision/detection/core.py @@ -267,6 +267,13 @@ class Detections: }, ) + if hasattr(ultralytics_results, "boxes") and ultralytics_results.boxes is None: + return cls( + xyxy=np.empty((1, 4)), + mask=extract_ultralytics_masks(ultralytics_results), + class_id=np.array([0]) + ) + class_id = ultralytics_results.boxes.cls.cpu().numpy().astype(int) class_names = np.array([ultralytics_results.names[i] for i in class_id]) return cls(