detections __getitem__: earlier check for empty detections

This commit is contained in:
LinasKo committed 2024-12-03 13:12:14 +02:00
1 parent 28fa054fdc
commit a4dfcacbfd
1 file changed
+2 -2
+2 -2
View File
@@ -1201,10 +1201,10 @@ class Detections:
"""
if isinstance(index, str):
return self.data.get(index)
if isinstance(index, int):
index = [index]
if self.is_empty():
return Detections.empty()
if isinstance(index, int):
index = [index]
return Detections(
xyxy=self.xyxy[index],
mask=self.mask[index] if self.mask is not None else None,