Datasets:

ArXiv:
License:
File size: 2,734 Bytes
a3341ee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from ._base_metric import _BaseMetric
from trackeval import _timing


class Count(_BaseMetric):
    """
    Class which simply counts the number of tracker and gt detections and ids.
    
    :param Dict config: configuration for the app
    ::

        identity = trackeval.metrics.Count(config)
    """
    def __init__(self, config=None):
        super().__init__()
        self.integer_fields = ['Dets', 'GT_Dets', 'IDs', 'GT_IDs']
        self.fields = self.integer_fields
        self.summary_fields = self.fields

    @_timing.time
    def eval_sequence(self, data):
        """
        Returns counts for one sequence
        
        :param Dict data: dictionary containing the data for the sequence
        
        :return: dictionary containing the calculated count metrics
        :rtype: Dict[str, Dict[str]]
        """
        # Get results
        res = {'Dets': data['num_tracker_dets'],
               'GT_Dets': data['num_gt_dets'],
               'IDs': data['num_tracker_ids'],
               'GT_IDs': data['num_gt_ids'],
               'Frames': data['num_timesteps']}
        return res

    def combine_sequences(self, all_res):
        """
        Combines metrics across all sequences
        
        :param Dict[str, float] all_res: dictionary containing the metrics for each sequence        
        :return: dictionary containing the combined metrics across sequences
        :rtype: Dict[str, float]
        """
        res = {}
        for field in self.integer_fields:
            res[field] = self._combine_sum(all_res, field)
        return res

    def combine_classes_class_averaged(self, all_res, ignore_empty_classes=None):
        """
        Combines metrics across all classes by averaging over the class values
        
        :param Dict[str, float] all_res: dictionary containing the ID metrics for each class
        :param bool ignore_empty_classes: Flag to ignore empty classes, defaults to False
        :return: dictionary containing the combined metrics averaged over classes
        :rtype: Dict[str, float]
        """
        res = {}
        for field in self.integer_fields:
            res[field] = self._combine_sum(all_res, field)
        return res

    def combine_classes_det_averaged(self, all_res):
        """
        Combines metrics across all classes by averaging over the detection values
        
        :param Dict[str, float] all_res: dictionary containing the metrics for each class        
        :return: dictionary containing the combined metrics averaged over detections
        :rtype: Dict[str, float]
        """
        res = {}
        for field in self.integer_fields:
            res[field] = self._combine_sum(all_res, field)
        return res