File size: 1,281 Bytes
14114e8 |
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 |
# fmt: off
# flake8: noqa
import csv
import os
from collections import OrderedDict
def validate_metrics_list(metrics_list):
"""Get names of metric class and ensures they are unique, further checks that the fields within each metric class
do not have overlapping names.
"""
metric_names = [metric.get_name() for metric in metrics_list]
# check metric names are unique
if len(metric_names) != len(set(metric_names)):
raise TrackEvalException(
"Code being run with multiple metrics of the same name"
)
fields = []
for m in metrics_list:
fields += m.fields
# check metric fields are unique
if len(fields) != len(set(fields)):
raise TrackEvalException(
"Code being run with multiple metrics with fields of the same name"
)
return metric_names
def get_track_id_str(ann):
"""Get name of track ID in annotation."""
if "track_id" in ann:
tk_str = "track_id"
elif "instance_id" in ann:
tk_str = "instance_id"
elif "scalabel_id" in ann:
tk_str = "scalabel_id"
else:
assert False, "No track/instance ID."
return tk_str
class TrackEvalException(Exception):
"""Custom exception for catching expected errors."""
...
|