Spaces:
Sleeping
Sleeping
recognition_th
Browse files
mot-metrics.py → user-friendly-metrics.py
RENAMED
@@ -15,6 +15,10 @@
|
|
15 |
import evaluate
|
16 |
import datasets
|
17 |
import motmetrics as mm
|
|
|
|
|
|
|
|
|
18 |
import numpy as np
|
19 |
|
20 |
_CITATION = """\
|
@@ -53,7 +57,7 @@ Args:
|
|
53 |
|
54 |
|
55 |
@evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
|
56 |
-
class
|
57 |
"""TODO: Short description of my evaluation module."""
|
58 |
|
59 |
def _info(self):
|
@@ -89,7 +93,14 @@ class MotMetrics(evaluate.Metric):
|
|
89 |
return calculate_from_payload(payload, max_iou, debug)
|
90 |
#return calculate(predictions, references, max_iou)
|
91 |
|
92 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
"""Returns the scores"""
|
94 |
|
95 |
try:
|
@@ -124,8 +135,16 @@ def calculate(predictions, references, max_iou: float = 0.5):
|
|
124 |
|
125 |
mh = mm.metrics.create()
|
126 |
summary = mh.compute(acc).to_dict()
|
|
|
|
|
|
|
|
|
|
|
127 |
for key in summary:
|
128 |
summary[key] = summary[key][0]
|
|
|
|
|
|
|
129 |
|
130 |
return summary
|
131 |
|
|
|
15 |
import evaluate
|
16 |
import datasets
|
17 |
import motmetrics as mm
|
18 |
+
from motmetrics.metrics import (events_to_df_map,
|
19 |
+
obj_frequencies,
|
20 |
+
track_ratios,
|
21 |
+
num_gt_ids)
|
22 |
import numpy as np
|
23 |
|
24 |
_CITATION = """\
|
|
|
57 |
|
58 |
|
59 |
@evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
|
60 |
+
class UserFriendlyMetrics(evaluate.Metric):
|
61 |
"""TODO: Short description of my evaluation module."""
|
62 |
|
63 |
def _info(self):
|
|
|
93 |
return calculate_from_payload(payload, max_iou, debug)
|
94 |
#return calculate(predictions, references, max_iou)
|
95 |
|
96 |
+
def recognition(track_ratios, th = 0.5):
|
97 |
+
"""Number of objects tracked for at least 20 percent of lifespan."""
|
98 |
+
return track_ratios[track_ratios >= th].count()
|
99 |
+
|
100 |
+
def calculate(predictions,
|
101 |
+
references,
|
102 |
+
max_iou: float = 0.5,
|
103 |
+
recognition_thresholds: list = [0.3, 0.5, 0.8],):
|
104 |
"""Returns the scores"""
|
105 |
|
106 |
try:
|
|
|
135 |
|
136 |
mh = mm.metrics.create()
|
137 |
summary = mh.compute(acc).to_dict()
|
138 |
+
|
139 |
+
df = events_to_df_map(acc.events)
|
140 |
+
tr_ratios = track_ratios(df, obj_frequencies(df))
|
141 |
+
unique_gt_ids = num_gt_ids(df)
|
142 |
+
|
143 |
for key in summary:
|
144 |
summary[key] = summary[key][0]
|
145 |
+
|
146 |
+
for th in recognition_thresholds:
|
147 |
+
summary[f'recognition_{th}'] = recognition(tr_ratios, th)
|
148 |
|
149 |
return summary
|
150 |
|