lingvo.tasks.car.breakdown_metric module

Library for calculating precision recall conditioned on a variate.

ByDistance: Calculate precision recall based on distance in world coordinates. ByRotation: Calculate precision recall based on rotation in world coordinates. ByNumPoints: Calculate maximum recall based on number of points in bounding box. ByDifficulty: Calculate precision recall based on difficulty.

lingvo.tasks.car.breakdown_metric._FindRecallAtGivenPrecision(precision_recall, precision_level)[source]

Find the recall at given precision level.

Parameters
  • precision_recall – np.array of shape [n, m, 2] where n is the number of classes, m is then number of values in the curve, 2 indexes between precision [0] and recall [1]. np.float32.

  • precision_level – float32. Selected precision level between (0, 1). Typically, this may be 0.95.

Returns

np.array of shape [n] consisting of recall for all classes

where the values are 0.0 if a given precision is never achieved.

Return type

recall

lingvo.tasks.car.breakdown_metric._FindMaximumRecall(precision_recall)[source]

Find the maximum recall in all precision recall curves.

Parameters

precision_recall – np.array of shape [n, m, 2] where n is the number of classes, m is then number of values in the curve, 2 indexes between precision [0] and recall [1]. np.float32.

Returns

np.array of shape [n] consisting of max recall for all classes

where the values are 0.0 if objects are found.

Return type

max_recall

class lingvo.tasks.car.breakdown_metric.BreakdownMetric(p)[source]

Bases: object

Base class for calculating precision recall conditioned on a variate.

classmethod Params()[source]
NumBinsOfHistogram()[source]

Returns int32 of number of bins in histogram.

ComputeMetrics(compute_metrics_fn)[source]

Compute precision-recall analysis conditioned on particular metric.

Parameters

compute_metrics_fn – Function that that calculates precision-recall metrics and accepts named arguments for conditioning. Typically, this would be APMetrics._ComputeFinalMetrics().

Returns

nothing

GenerateSummaries(name)[source]

Generate list of image summaries plotting precision-recall analysis.

Parameters

name – string providing scope

Returns

list of image summaries

Discretize(values)[source]

Discretize statistics into integer values.

Parameters

values – 1-D np.array of variate to be discretized.

Returns

1-D np.array of int32 ranging within [0, cls.NumOfBinsOfHistogram()]

_AccumulateHistogram(statistics=None, labels=None)[source]

Accumulate histogram of binned statistic by label.

Parameters
  • statistics – int32 np.array of shape [K, 1] of binned statistic

  • labels – int32 np.array of shape [K, 1] of labels

Returns

nothing

_AccumulateCumulative(statistics=None, labels=None)[source]

Accumulate cumulative of real-valued statistic by label.

Parameters
  • statistics – float32 np.array of shape [K, 1] of statistic

  • labels – int32 np.array of shape [K, 1] of labels

Returns

nothing

AccumulateCumulative(result)[source]

Accumulate cumulative of real-valued statistic by label.

Parameters

result – A NestedMap with these fields: .labels: [N]. Groundtruth boxes’ labels. .bboxes: [N, 7]. Groundtruth boxes coordinates. .difficulties: [N]. Groundtruth boxes difficulties. .num_points: [N]. Number of laser points in bounding boxes.

Returns

nothing

lingvo.tasks.car.breakdown_metric.ByName(breakdown_metric_name)[source]

Return a BreakdownMetric class by name.

class lingvo.tasks.car.breakdown_metric.ByDistance(p)[source]

Bases: lingvo.tasks.car.breakdown_metric.BreakdownMetric

Calculate average precision as function of distance.

NumBinsOfHistogram()[source]

Returns int32 of number of bins in histogram.

classmethod _CalculateEuclideanDistanceFromOrigin(bboxes)[source]

Calculate the Euclidean distance from the origin for each bounding box.

Note that the LabelsExtractor originally returns groundtruth_bboxes of shape [N, 7] where N is the number of bounding boxes. The last axis is ordered [x, y, z, w, h, d, phi]. Hence, the Euclidean distance to the origin is the L2 norm of the first 3 entries.

Parameters

bboxes – [N, 7] np.float of N bounding boxes. See details above.

Returns

np.array [N] of Euclidean distances.

Discretize(bboxes)[source]

Discretize statistics into integer values.

Parameters

values – 1-D np.array of variate to be discretized.

Returns

1-D np.array of int32 ranging within [0, cls.NumOfBinsOfHistogram()]

AccumulateHistogram(result)[source]
ComputeMetrics(compute_metrics_fn)[source]

Compute precision-recall analysis conditioned on particular metric.

Parameters

compute_metrics_fn – Function that that calculates precision-recall metrics and accepts named arguments for conditioning. Typically, this would be APMetrics._ComputeFinalMetrics().

Returns

nothing

GenerateSummaries(name)[source]

Generate an image summary for AP versus distance by class.

class lingvo.tasks.car.breakdown_metric.ByNumPoints(p)[source]

Bases: lingvo.tasks.car.breakdown_metric.BreakdownMetric

Calculate average precision as function of the number of points.

NumBinsOfHistogram()[source]

Returns int32 of number of bins in histogram.

_LogSpacedBinEdgesofPoints()[source]
Discretize(num_points)[source]

Discretize statistics into integer values.

Parameters

values – 1-D np.array of variate to be discretized.

Returns

1-D np.array of int32 ranging within [0, cls.NumOfBinsOfHistogram()]

AccumulateHistogram(result)[source]
AccumulateCumulative(result)[source]

Accumulate cumulative of real-valued statistic by label.

Parameters

result – A NestedMap with these fields: .labels: [N]. Groundtruth boxes’ labels. .bboxes: [N, 7]. Groundtruth boxes coordinates. .difficulties: [N]. Groundtruth boxes difficulties. .num_points: [N]. Number of laser points in bounding boxes.

Returns

nothing

ComputeMetrics(compute_metrics_fn)[source]

Compute precision-recall analysis conditioned on particular metric.

Parameters

compute_metrics_fn – Function that that calculates precision-recall metrics and accepts named arguments for conditioning. Typically, this would be APMetrics._ComputeFinalMetrics().

Returns

nothing

GenerateSummaries(name)[source]

Generate an image summary for max recall by number of points by class.

_GenerateCumulativeSummaries(name)[source]

Generate an image summary for CDF of a variate.

class lingvo.tasks.car.breakdown_metric.ByRotation(p)[source]

Bases: lingvo.tasks.car.breakdown_metric.BreakdownMetric

Calculate average precision as function of rotation.

NumBinsOfHistogram()[source]

Returns int32 of number of bins in histogram.

_CalculateRotation(bboxes)[source]

Calculate rotation angle mod between (0, 2 * pi) for each box.

Parameters

bboxes – [N, 7] np.float of N bounding boxes. See details above.

Returns

np.array [N] of rotation angles in radians.

Discretize(bboxes)[source]

Discretize statistics into integer values.

Parameters

values – 1-D np.array of variate to be discretized.

Returns

1-D np.array of int32 ranging within [0, cls.NumOfBinsOfHistogram()]

AccumulateHistogram(result)[source]
ComputeMetrics(compute_metrics_fn)[source]

Compute precision-recall analysis conditioned on particular metric.

Parameters

compute_metrics_fn – Function that that calculates precision-recall metrics and accepts named arguments for conditioning. Typically, this would be APMetrics._ComputeFinalMetrics().

Returns

nothing

GenerateSummaries(name)[source]

Generate an image summary for AP versus rotation by class.

class lingvo.tasks.car.breakdown_metric.ByDifficulty(p)[source]

Bases: lingvo.tasks.car.breakdown_metric.BreakdownMetric

Calculate average precision as function of difficulty.

classmethod Params()[source]
NumBinsOfHistogram()[source]

Returns int32 of number of bins in histogram.

Discretize(difficulties)[source]

Discretize statistics into integer values.

Parameters

values – 1-D np.array of variate to be discretized.

Returns

1-D np.array of int32 ranging within [0, cls.NumOfBinsOfHistogram()]

AccumulateHistogram(result)[source]
ComputeMetrics(compute_metrics_fn)[source]

Compute precision-recall analysis conditioned on particular metric.

Parameters

compute_metrics_fn – Function that that calculates precision-recall metrics and accepts named arguments for conditioning. Typically, this would be APMetrics._ComputeFinalMetrics().

Returns

nothing

GenerateSummaries(name)[source]

Generate an image summary for PR by difficulty and for calibration.

Parameters

name – str, name of summary.

Returns

list of summaries