diff --git a/supervision/detection/core.py b/supervision/detection/core.py index d31e07bd..da90cb10 100644 --- a/supervision/detection/core.py +++ b/supervision/detection/core.py @@ -865,6 +865,9 @@ class Detections: if lmm == LMM.FLORENCE_2: assert isinstance(result, dict) xyxy, labels, xyxyxyxy = from_florence_2(result, **kwargs) + if len(xyxy) == 0: + return cls.empty() + data = {} if labels is not None: data[CLASS_NAME_DATA_FIELD] = labels diff --git a/supervision/detection/lmm.py b/supervision/detection/lmm.py index 910ca30c..e70170ab 100644 --- a/supervision/detection/lmm.py +++ b/supervision/detection/lmm.py @@ -121,7 +121,6 @@ def from_florence_2( xyxyxyxy = np.array(result["quad_boxes"], dtype=np.float32) xyxyxyxy = xyxyxyxy.reshape(-1, 4, 2) xyxy = np.array([polygon_to_xyxy(polygon) for polygon in xyxyxyxy]) - labels = np.array(result["labels"]) return xyxy, labels, xyxyxyxy