Merge pull request #1698 from souhhmm/fix/xyxy-shape-crash
fix: is_empty check for filtering
This commit is contained in:
commit
ae8e6b2976
|
|
@ -1201,6 +1201,8 @@ class Detections:
|
|||
"""
|
||||
if isinstance(index, str):
|
||||
return self.data.get(index)
|
||||
if self.is_empty():
|
||||
return Detections.empty()
|
||||
if isinstance(index, int):
|
||||
index = [index]
|
||||
return Detections(
|
||||
|
|
|
|||
|
|
@ -223,6 +223,12 @@ TEST_DET_DIFFERENT_METADATA = Detections(
|
|||
None,
|
||||
pytest.raises(IndexError),
|
||||
),
|
||||
(
|
||||
Detections.empty(),
|
||||
np.isin(Detections.empty()["class_name"], ["cat", "dog"]),
|
||||
Detections.empty(),
|
||||
DoesNotRaise(),
|
||||
), # Filter an empty detections by specific class names
|
||||
],
|
||||
)
|
||||
def test_getitem(
|
||||
|
|
|
|||
Loading…
Reference in New Issue