Beispiel #1
0
  def testAccumulateHistogram(self):
    metadata = kitti_metadata.KITTIMetadata()
    num_per_class = np.arange(metadata.NumClasses()) + 1
    statistics = [
        1 * np.ones(shape=(np.sum(num_per_class)), dtype=np.int32),
        2 * np.ones(shape=(np.sum(2 * num_per_class)), dtype=np.int32)
    ]
    statistics = np.concatenate(statistics)

    labels = []
    for i, n in enumerate(num_per_class):
      labels.extend([i] * n)
    for i, n in enumerate(num_per_class):
      labels.extend([i] * 2 * n)
    labels = np.array(labels)
    assert len(statistics) == len(labels)

    metrics_params = breakdown_metric.BreakdownMetric.Params().Set(
        metadata=metadata)
    test_breakdown_metric = breakdown_metric.ByDifficulty(metrics_params)
    test_breakdown_metric._AccumulateHistogram(
        statistics=statistics, labels=labels)

    for class_index, n in enumerate(num_per_class):
      self.assertEqual(n, test_breakdown_metric._histogram[1, class_index])
      self.assertEqual(2 * n, test_breakdown_metric._histogram[2, class_index])
Beispiel #2
0
  def __init__(self, params):
    super(WaymoAPMetrics, self).__init__(params)
    self._waymo_metric_config = _BuildWaymoMetricConfig(
        self.metadata, self.params.box_type,
        self.params.waymo_breakdown_metrics)
    # Add APH metric.
    metrics_params = breakdown_metric.ByDifficulty.Params().Set(
        metadata=self.metadata,
        ap_key='ap_ha_weighted',
        pr_key='pr_ha_weighted')
    self._breakdown_metrics['aph'] = breakdown_metric.ByDifficulty(
        metrics_params)

    # Compute extra breakdown metrics.
    breakdown_names = config_util.get_breakdown_names_from_config(
        self._waymo_metric_config)
    waymo_params = WaymoBreakdownMetric.Params().Set(
        metadata=self.metadata, breakdown_list=breakdown_names[1:])
    self._breakdown_metrics['waymo'] = WaymoBreakdownMetric(waymo_params)
Beispiel #3
0
  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))