-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathtracker_evaluator.py
More file actions
98 lines (74 loc) · 2.45 KB
/
tracker_evaluator.py
File metadata and controls
98 lines (74 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# SPDX-FileCopyrightText: (C) 2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Base class for tracker evaluator implementations."""
from abc import ABC, abstractmethod
from typing import Iterator, List, Dict, Any
from pathlib import Path
class TrackerEvaluator(ABC):
"""Base class for tracker evaluator implementations.
A tracker evaluator computes tracking quality metrics by comparing
tracker outputs against ground-truth data.
It consumes:
- Tracker outputs in canonical format
- Ground-truth tracks in evaluator-specific format
It produces:
- Metrics dictionary
- Optional plots and detailed results
"""
@abstractmethod
def configure_metrics(self, metrics: List[str]) -> 'TrackerEvaluator':
"""Configure which metrics to evaluate.
Args:
metrics: List of metric names to compute (e.g., ['HOTA', 'MOTA', 'IDF1']).
Returns:
Self for method chaining.
Raises:
ValueError: If any metric name is not supported.
RuntimeError: On other errors.
"""
pass
@abstractmethod
def set_output_folder(self, path: Path) -> 'TrackerEvaluator':
"""Set folder where evaluation outputs should be stored.
Args:
path: Path to results folder. Will be created if it doesn't exist.
Returns:
Self for method chaining.
Raises:
ValueError: If path is invalid.
RuntimeError: On other errors.
"""
pass
@abstractmethod
def process_tracker_outputs(
self,
tracker_outputs: Iterator[Dict[str, Any]],
ground_truth: Iterator[Dict[str, Any]]
) -> 'TrackerEvaluator':
"""Process tracker outputs and ground-truth for evaluation.
Args:
tracker_outputs: Iterator of tracker output dictionaries in canonical Tracker Output Format
(see tools/tracker/evaluation/README.md#canonical-data-formats).
ground_truth: Iterator of ground-truth tracks in evaluator-specific format.
Returns:
Self for method chaining.
Raises:
RuntimeError: If processing fails.
"""
pass
@abstractmethod
def evaluate_metrics(self) -> Dict[str, float]:
"""Evaluate configured metrics.
Returns:
Dictionary mapping metric names to computed values.
Raises:
RuntimeError: If evaluation fails or no data has been processed.
"""
pass
@abstractmethod
def reset(self) -> 'TrackerEvaluator':
"""Reset evaluator state to initial configuration.
Returns:
Self for method chaining.
"""
pass