lingvo.tasks.car.detection_decoder module¶
Functions to help with decoding detector model outputs.
-
lingvo.tasks.car.detection_decoder.DecodeWithNMS(predicted_bboxes, classification_scores, nms_iou_threshold, score_threshold, max_boxes_per_class=None, use_oriented_per_class_nms=False)[source]¶ Perform NMS on predicted bounding boxes / associated logits.
- Parameters
predicted_bboxes – [batch_size, num_boxes, 7] float Tensor containing predicted bounding box coordinates.
classification_scores – [batch_size, num_boxes, num_classes] float Tensor containing predicted classification scores for each box.
nms_iou_threshold – IoU threshold to use when determining whether two boxes overlap for purposes of suppression. Either a float or a list of len num_classes.
score_threshold – The score threshold passed to NMS that allows NMS to quickly ignore irrelevant boxes. Either a float or a list of len num_classes.
max_boxes_per_class – The maximum number of boxes per example to emit. If None, this value is set to num_boxes from the shape of predicted_bboxes.
use_oriented_per_class_nms – Whether to use the oriented per class NMS or treat everything as one class and having no orientation.
- Returns
- Indices of the boxes selected after NMS. Tensor of shape
[batch_size, num_classes, max_boxes_per_class] if per class NMS is used. If single class NMS, this will be of shape [batch_size, max_boxes_per_class].
- predicted_bboxes: Filtered bboxes after NMS of shape
[batch_size, num_classes, max_boxes_per_class, 7].
- bbox_scores: A float32 Tensor with the score for each box of shape
[batch_size, num_classes, max_boxes_per_class].
- valid_mask: A float32 Tensor with 1/0 values indicating the validity of
each box. 1 indicates valid, and 0 invalid. Tensor of shape [batch_size, num_classes, max_boxes_per_class].
- Return type
bbox_indices
-
lingvo.tasks.car.detection_decoder._MultiClassOrientedDecodeWithNMS(predicted_bboxes, classification_scores, nms_iou_threshold, score_threshold, max_boxes_per_class=None)[source]¶ Perform Oriented Per Class NMS on predicted bounding boxes / logits.
- Parameters
predicted_bboxes – [batch_size, num_boxes, 7] float Tensor containing predicted bounding box coordinates.
classification_scores – [batch_size, num_boxes, num_classes] float Tensor containing predicted classification scores for each box.
nms_iou_threshold – IoU threshold to use when determining whether two boxes overlap for purposes of suppression. Either a float or a list of len num_classes.
score_threshold – The score threshold passed to NMS that allows NMS to quickly ignore irrelevant boxes. Either a float or a list of len num_classes. It is strongly recommended that the score for non-active classes (like background) be set to 1 so they are discarded.
max_boxes_per_class – The maximum number of boxes per example to emit. If None, this value is set to num_boxes from the shape of predicted_bboxes.
- Returns
- Indices of the boxes selected after NMS. Tensor of shape
[batch_size, num_classes, max_boxes_per_class].
- predicted_bboxes: Filtered bboxes after NMS of shape
[batch_size, num_classes, max_boxes_per_class, 7].
- bbox_scores: A float32 Tensor with the score for each box of shape
[batch_size, num_classes, max_boxes_per_class].
- valid_mask: A float32 Tensor with 1/0 values indicating the validity of
each box. 1 indicates valid, and 0 invalid. Tensor of shape [batch_size, num_classes, max_boxes_per_class].
- Return type
bbox_indices
-
lingvo.tasks.car.detection_decoder._SingleClassDecodeWithNMS(predicted_bboxes, classification_scores, nms_iou_threshold, score_threshold, max_boxes_per_class=None)[source]¶ Perform NMS on predicted bounding boxes / associated logits.
- Parameters
predicted_bboxes – [batch_size, num_boxes, 7] float Tensor containing predicted bounding box coordinates.
classification_scores – [batch_size, num_boxes, num_classes] float Tensor containing predicted classification scores for each box.
nms_iou_threshold – IoU threshold to use when determining whether two boxes overlap for purposes of suppression.
score_threshold – The score threshold passed to NMS that allows NMS to quickly ignore irrelevant boxes.
max_boxes_per_class – The maximum number of boxes per example to emit. If None, this value is set to num_boxes from the shape of predicted_bboxes.
- Returns
- Indices of the boxes selected after NMS. Tensor of shape
[batch_size, num_classes, max_boxes_per_class].
- predicted_bboxes: Filtered bboxes after NMS of shape
[batch_size, num_classes, max_boxes_per_class, 7].
- bbox_scores: A float32 Tensor with the score for each box of shape
[batch_size, num_classes, max_boxes_per_class].
- valid_mask: A float32 Tensor with 1/0 values indicating the validity of
each box. 1 indicates valid, and 0 invalid. Tensor of shape [batch_size, num_classes, max_boxes_per_class].
- Return type
nms_indices