lingvo.tasks.car.ap_metric module¶
Average precision metric interface.
-
class
lingvo.tasks.car.ap_metric.Boxes3D[source]¶ Bases:
objectA container for a list of 7-DOF 3D boxes.
Each 3D box is represented by the 7-tuple [x, y, z, dx, dy, dz, phi], where x, y, z is the center of the box, dx, dy, dz represent the width, length, and height of the box, and phi is the rotation of the box.
-
Add(img_id, score, box, difficulty, distance, num_points, rotation, height_in_pixels, speed)[source]¶ Adds a bbox.
- Parameters
img_id – A unique image identifier.
score – The confidence score.
box – [1 x 7] numpy array.
difficulty – The difficulty of a box. On KITTI this is one of [0, 1, 2, 3].
distance – The binned distance of a box.
num_points – Number of laser points in box.
rotation – The binned rotation of a box.
height_in_pixels – The height of the 2D bbox of this object in the camera image.
speed – A [1 x 2] numpy array with speed of object in world frame.
-
property
imgids¶
-
property
scores¶
-
property
boxes¶
-
property
difficulties¶
-
property
distances¶
-
property
num_points¶
-
property
rotations¶
-
property
heights_in_pixels¶
-
property
speeds¶
-
-
class
lingvo.tasks.car.ap_metric.APMetrics(params)[source]¶ Bases:
lingvo.core.metrics.BaseMetricMeasure an assortment of precision-recall metrics on a dataset.
-
_LoadBoundingBoxes(box_type, class_id, distance=None, num_points=None, rotation=None)[source]¶ Load a specified set of bounding boxes.
If no boxes are found, return None.
Note that we do not specify ‘difficulty’ as an option due to how the KITTI evaluates bounding boxes across difficulty levels.
- Parameters
box_type – string. Either ‘groundtruth’ or ‘prediction’
class_id – int32 specifying the class
distance – int32 specifying a binned Euclidean distance of the ground truth bounding box. If None is specified, all distances are selected.
num_points – int32 specifying a binned number of laser points within the ground truth bounding box. If None is specified, all boxes are selected.
rotation – int32 specifying a binned rotation within the ground truth bounding box. If None is specified, all boxes are selected.
- Returns
Boxes3D containing bounding boxes or None if no bounding boxes available.
-
_GetData(classid, difficulty=None, distance=None, num_points=None, rotation=None)[source]¶ Returns groundtruth and prediction for the classid in a NestedMap.
- Parameters
classid – int32 specifying the class
difficulty – String in [easy, moderate, hard]. If None specified, all difficulty levels are permitted.
distance – int32 specifying a binned Euclidean distance of the ground truth bounding box. If None is specified, all distances are selected.
num_points – int32 specifying a binned number of laser points within the ground truth bounding box. If None is specified, all boxes are selected.
rotation – int32 specifying a binned rotation within the ground truth bounding box. If None is specified, all boxes are selected.
- Returns
NestedMap containing iou_threshold, groundtruth and predictions for specified, classid, difficulty level and binned distance. If no bboxes are found with these parameters, returns None.
-
_ComputeFinalMetrics(classids=None, difficulty=None, distance=None, num_points=None, rotation=None)[source]¶ Compute precision-recall curves as well as average precision.
- Parameters
classids – A list of N int32.
difficulty – String in [easy, moderate, hard]. If None specified, all difficulty levels are permitted.
distance – int32 specifying a binned Euclidean distance of the ground truth bounding box. If None is specified, all distances are selected.
num_points – int32 specifying a binned number of laser points within the ground truth bounding box. If None is specified, all boxes are selected.
rotation – int32 specifying a binned rotation within the ground truth bounding box. If None is specified, all boxes are selected.
- Returns
dict. Each entry in the dict is a list of C (number of classes) dicts containing mapping from metric names to individual results. Individual entries may be the following items. - scalars: A list of C (number of classes) dicts mapping metric names to scalar values. - curves: A list of C dicts mapping metrics names to np.float32 arrays of shape [NumberOfPrecisionRecallPoints()+1, 2]. In the last dimension, 0 indexes precision and 1 indexes recall. - calibrations: A list of C dicts mapping metrics names to np.float32 arrays of shape [number of predictions, 2]. The first column is the predicted probabilty and the second column is 0 or 1 indicating that the prediction matched a ground truth item.
-
Update(str_id, result)[source]¶ Update this metric with a newly evaluated image.
- Parameters
str_id – A string. Unique identifier of an image.
result –
A NestedMap with these fields: groundtruth_labels - [N]. Groundtruth boxes’ labels.
groundtruth_bboxes - [N, 7]. Groundtruth boxes coordinates.
groundtruth_difficulties - [N]. Groundtruth boxes difficulties.
groundtruth_num_points - [N]. Number of laser points in bounding boxes.
- groundtruth_speed - [N, 2] Speed in (vx, vy) of the ground truth
object.
detection_scores - [C, M] - For each class (C classes) we have (up to) M predicted boxes.
detection_boxes - [C, M, 7] - [i, j, :] are coordinates for i-th classes j-th predicted box.
detection_heights_in_pixels - [C, M]. [i, j] is the height of i-th classes j-th boxes 2D image coordinate (camera view).
-
property
value¶ Current value of this metric.
-