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:
objectBase class for calculating precision recall conditioned on a variate.
-
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.BreakdownMetricCalculate average precision as function of distance.
-
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()]
-
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
-
classmethod
-
class
lingvo.tasks.car.breakdown_metric.ByNumPoints(p)[source]¶ Bases:
lingvo.tasks.car.breakdown_metric.BreakdownMetricCalculate average precision as function of the number of points.
-
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()]
-
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
-
-
class
lingvo.tasks.car.breakdown_metric.ByRotation(p)[source]¶ Bases:
lingvo.tasks.car.breakdown_metric.BreakdownMetricCalculate average precision as function of rotation.
-
_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()]
-
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
-
-
class
lingvo.tasks.car.breakdown_metric.ByDifficulty(p)[source]¶ Bases:
lingvo.tasks.car.breakdown_metric.BreakdownMetricCalculate average precision as function of difficulty.
-
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()]
-
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
-