Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for mmdet tracking #1404

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions supervision/detection/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,21 @@ def from_mmdetection(cls, mmdet_results) -> Detections:
detections = sv.Detections.from_mmdetection(result)
```
""" # noqa: E501 // docs
if (
hasattr(mmdet_results, "pred_track_instances")
and mmdet_results.pred_track_instances is not None
):
return cls(
xyxy=mmdet_results.pred_track_instances.bboxes.cpu().numpy(),
confidence=mmdet_results.pred_track_instances.scores.cpu().numpy(),
class_id=mmdet_results.pred_track_instances.labels.cpu().numpy(),
mask=mmdet_results.pred_track_instances.masks.cpu().numpy()
if "masks" in mmdet_results.pred_track_instances
else None,
tracker_id=mmdet_results.pred_track_instances.instances_id.cpu().numpy()
if "instances_id" in mmdet_results.pred_track_instances
else None,
)

return cls(
xyxy=mmdet_results.pred_instances.bboxes.cpu().numpy(),
Expand Down