diff --git a/supervision/detection/core.py b/supervision/detection/core.py index 89a526d62..30e44d848 100644 --- a/supervision/detection/core.py +++ b/supervision/detection/core.py @@ -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(),