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