rpx_benchmark.metrics.tracking
Multi-object tracking metric calculators.
1"""Multi-object tracking metric calculators.""" 2 3from __future__ import annotations 4 5from typing import Dict 6 7from ..api import TaskType, TrackletGroundTruth, TrackletPrediction 8from ..exceptions import MetricError 9from .registry import MetricCalculator, register_metric 10 11 12@register_metric(TaskType.OBJECT_TRACKING) 13class TrackletMetrics(MetricCalculator): 14 """Simplified MOTA + IDF1 over a single tracklet sample. 15 16 Parameters 17 ---------- 18 iou_threshold : float 19 IoU required to count a predicted detection as a hit for a 20 given GT box. Default 0.5. 21 22 Notes 23 ----- 24 This is the per-sample version called by the runner. A full MOTA 25 computation (with cross-scene identity switches) lives in 26 :mod:`rpx_benchmark.deployment` and runs on the whole dataset. 27 """ 28 29 name = "tracklet_metrics" 30 31 def __init__(self, iou_threshold: float = 0.5) -> None: 32 self.iou_threshold = iou_threshold 33 34 def compute( 35 self, 36 prediction: TrackletPrediction, 37 ground_truth: TrackletGroundTruth, 38 ) -> Dict[str, float]: 39 if not isinstance(prediction, TrackletPrediction): 40 raise MetricError( 41 f"TrackletMetrics expected TrackletPrediction, got {type(prediction).__name__}", 42 ) 43 if not isinstance(ground_truth, TrackletGroundTruth): 44 raise MetricError( 45 f"TrackletMetrics expected TrackletGroundTruth, got {type(ground_truth).__name__}", 46 ) 47 from ..evaluators import tracking_metrics 48 49 return tracking_metrics( 50 prediction.tracks, 51 ground_truth.tracks, 52 iou_threshold=self.iou_threshold, 53 )
13@register_metric(TaskType.OBJECT_TRACKING) 14class TrackletMetrics(MetricCalculator): 15 """Simplified MOTA + IDF1 over a single tracklet sample. 16 17 Parameters 18 ---------- 19 iou_threshold : float 20 IoU required to count a predicted detection as a hit for a 21 given GT box. Default 0.5. 22 23 Notes 24 ----- 25 This is the per-sample version called by the runner. A full MOTA 26 computation (with cross-scene identity switches) lives in 27 :mod:`rpx_benchmark.deployment` and runs on the whole dataset. 28 """ 29 30 name = "tracklet_metrics" 31 32 def __init__(self, iou_threshold: float = 0.5) -> None: 33 self.iou_threshold = iou_threshold 34 35 def compute( 36 self, 37 prediction: TrackletPrediction, 38 ground_truth: TrackletGroundTruth, 39 ) -> Dict[str, float]: 40 if not isinstance(prediction, TrackletPrediction): 41 raise MetricError( 42 f"TrackletMetrics expected TrackletPrediction, got {type(prediction).__name__}", 43 ) 44 if not isinstance(ground_truth, TrackletGroundTruth): 45 raise MetricError( 46 f"TrackletMetrics expected TrackletGroundTruth, got {type(ground_truth).__name__}", 47 ) 48 from ..evaluators import tracking_metrics 49 50 return tracking_metrics( 51 prediction.tracks, 52 ground_truth.tracks, 53 iou_threshold=self.iou_threshold, 54 )
Simplified MOTA + IDF1 over a single tracklet sample.
Parameters
iou_threshold : float IoU required to count a predicted detection as a hit for a given GT box. Default 0.5.
Notes
This is the per-sample version called by the runner. A full MOTA
computation (with cross-scene identity switches) lives in
rpx_benchmark.deployment and runs on the whole dataset.
35 def compute( 36 self, 37 prediction: TrackletPrediction, 38 ground_truth: TrackletGroundTruth, 39 ) -> Dict[str, float]: 40 if not isinstance(prediction, TrackletPrediction): 41 raise MetricError( 42 f"TrackletMetrics expected TrackletPrediction, got {type(prediction).__name__}", 43 ) 44 if not isinstance(ground_truth, TrackletGroundTruth): 45 raise MetricError( 46 f"TrackletMetrics expected TrackletGroundTruth, got {type(ground_truth).__name__}", 47 ) 48 from ..evaluators import tracking_metrics 49 50 return tracking_metrics( 51 prediction.tracks, 52 ground_truth.tracks, 53 iou_threshold=self.iou_threshold, 54 )
Return a dict of metric name → scalar for one sample.
Parameters
prediction : Any
Task-specific Prediction dataclass
(e.g. DepthPrediction). The concrete type is
whatever the calculator is designed for.
ground_truth : Any
Task-specific GroundTruth dataclass
(e.g. DepthGroundTruth).
Returns
dict[str, float] Metric values. Keys should be short snake_case names; values must be numeric so the runner can average them.
Raises
MetricError When inputs have the wrong shape/type/content.