Bugfix: florence 2, handle case with no detections

This commit is contained in:
LinasKo
2024-06-20 15:49:13 +03:00
parent 2f88bb2b8e
commit 04c5f18da0
2 changed files with 3 additions and 1 deletions
+3
View File
@@ -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
-1
View File
@@ -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