def __init__(self, params): """Initialize the metrics.""" self.params = params.Copy() self._is_eval_complete = False self._groundtruth = {} # keyed by class id. self._prediction = {} # keyed by class id. self._str_to_imgid = {} self._iou_thresholds = self.params.metadata.IoUThresholds() self.metadata = self.params.metadata assert self.params.box_type in ['2d', '3d'] # We must always include ByDifficulty. metrics_params = breakdown_metric.ByDifficulty.Params().Set( metadata=self.metadata) self._breakdown_metrics = { 'difficulty': breakdown_metric.ByDifficulty(metrics_params) } for breakdown_metric_name in self.params.breakdown_metrics: self._breakdown_metrics[breakdown_metric_name] = ( breakdown_metric.ByName(breakdown_metric_name)(metrics_params))
def testByName(self): metric_class = breakdown_metric.ByName('difficulty') self.assertEqual(metric_class, breakdown_metric.ByDifficulty) with self.assertRaises(ValueError): breakdown_metric.ByName('undefined')