From 5bfd51fdec38fa163666ea8f538f44db71abcf2c Mon Sep 17 00:00:00 2001 From: LinasKo Date: Mon, 3 Jun 2024 14:01:03 +0200 Subject: [PATCH] is_empty check that includes data * We need to decide if this or from_inference data appended to empty Detections is correct --- supervision/detection/core.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/supervision/detection/core.py b/supervision/detection/core.py index 7699ade3..0abece68 100644 --- a/supervision/detection/core.py +++ b/supervision/detection/core.py @@ -929,9 +929,7 @@ class Detections: ``` """ detections_list = [ - detections - for detections in detections_list - if detections != Detections.empty() + detections for detections in detections_list if not is_empty(detections) ] if len(detections_list) == 0: @@ -1398,3 +1396,9 @@ def validate_fields_both_defined_or_none( f"Field '{attribute}' should be consistently None or not None in both " "Detections." ) + + +def is_empty(detections: Detections) -> bool: + empty_detections = Detections.empty() + empty_detections.data = detections.data + return detections == empty_detections