Skip to content

[Bug]: Inconsistent behavior of sv.Detections.is_empty() if tracker_id is not None #2195

Description

@UNakade

Search before asking

  • I have searched the issues and discussions and found no similar bug report.

Bug

If is_empty is called on a Detections object, False is returned if tracker_id is an empty array instead of None.

Environment

  • Supervision: 0.27.0.post2
  • Python: 3.10.20
  • OS: Ubuntu 24.04

Minimal Reproducible Example

import supervision as sv
import numpy as np

detections_wo_tracker_id = sv.Detections(
    xyxy=np.array([[0, 0, 10, 10], [0, 0, 20, 30]]), 
    class_id=np.array([1, 2]), 
    confidence=np.array([0.6, 0.7])
)
print(detections_wo_tracker_id[detections_wo_tracker_id.class_id == 0].is_empty())
# True

detections_w_tracker_id = sv.Detections(
    xyxy=np.array([[0, 0, 10, 10], [0, 0, 20, 30]]), 
    class_id=np.array([1, 2]), 
    confidence=np.array([0.6, 0.7]), 
    tracker_id=np.array([1, 2])
)
print(detections_w_tracker_id[detections_w_tracker_id.class_id == 0].is_empty())
# False

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions