Skip to content

Commit

Permalink
detections __getitem__: earlier check for empty detections
Browse files Browse the repository at this point in the history
  • Loading branch information
LinasKo committed Dec 3, 2024
1 parent 28fa054 commit a4dfcac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions supervision/detection/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1201,10 +1201,10 @@ def __getitem__(
"""
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,
Expand Down

0 comments on commit a4dfcac

Please sign in to comment.