vis4d.op.box.matchers

Matchers package.

class MatchResult(assigned_gt_indices: Tensor, assigned_gt_iou: Tensor, assigned_labels: Tensor)[source]

Match result class. Stores expected result tensors.

assigned_gt_indices: torch.Tensor - Tensor of [0, M) where M = num gt assigned_gt_iou: torch.Tensor - Tensor with IoU to assigned GT assigned_labels: torch.Tensor - Tensor of {0, -1, 1} = {neg, ignore, pos}

Create new instance of MatchResult(assigned_gt_indices, assigned_gt_iou, assigned_labels)

assigned_gt_indices: Tensor

Alias for field number 0

assigned_gt_iou: Tensor

Alias for field number 1

assigned_labels: Tensor

Alias for field number 2

class Matcher(*args, **kwargs)[source]

Base class for box / target matchers.

Initialize internal Module state, shared by both nn.Module and ScriptModule.

__call__(boxes, targets)[source]

Type declaration for forward.

Return type:

MatchResult

abstract forward(boxes, targets)[source]

Match bounding boxes according to their struct.

Return type:

MatchResult

class MaxIoUMatcher(thresholds, labels, allow_low_quality_matches, min_positive_iou=0.0)[source]

MaxIoUMatcher class.

Creates an instance of the class.

forward(boxes, targets)[source]

Match all boxes to targets based on maximum IoU.

Return type:

MatchResult

class SimOTAMatcher(center_radius=2.5, candidate_topk=10, iou_weight=3.0, cls_weight=1.0)[source]

SimOTA label assigner used by YOLOX.

Parameters:
  • center_radius (float, optional) – Ground truth center size to judge whether a prior is in center. Defaults to 2.5.

  • candidate_topk (int, optional) – The candidate top-k which used to get top-k ious to calculate dynamic-k. Defaults to 10.

  • iou_weight (float, optional) – The scale factor for regression iou cost. Defaults to 3.0.

  • cls_weight (float, optional) – The scale factor for classification cost. Defaults to 1.0.

Init.

__call__(pred_scores, priors, decoded_bboxes, gt_bboxes, gt_labels)[source]

Type declaration for forward.

Return type:

MatchResult

dynamic_k_matching(cost, pairwise_ious, num_gt, valid_mask)[source]

Dynamic K matching strategy.

Return type:

tuple[Tensor, Tensor]

forward(pred_scores, priors, decoded_bboxes, gt_bboxes, gt_labels)[source]

Assign gt to priors using SimOTA.

Parameters:
  • pred_scores (Tensor) – Classification scores of one image, a 2D-Tensor with shape [num_priors, num_classes]

  • priors (Tensor) – All priors of one image, a 2D-Tensor with shape [num_priors, 4] in [cx, xy, stride_w, stride_y] format.

  • decoded_bboxes (Tensor) – Predicted bboxes, a 2D-Tensor with shape [num_priors, 4] in [tl_x, tl_y, br_x, br_y] format.

  • gt_bboxes (Tensor) – Ground truth bboxes of one image, a 2D-Tensor with shape [num_gts, 4] in [tl_x, tl_y, br_x, br_y] format.

  • gt_labels (Tensor) – Ground truth labels of one image, a Tensor with shape [num_gts].

Returns:

The assigned result.

Return type:

MatchResult

get_in_gt_and_in_center_info(priors, gt_bboxes)[source]

Get whether the priors are in gt bboxes and in centers.

Return type:

tuple[Tensor, Tensor]

Modules

vis4d.op.box.matchers.base

Matchers.

vis4d.op.box.matchers.max_iou

Match predictions and targets according to maximum 2D IoU.

vis4d.op.box.matchers.sim_ota

SimOTA label assigner.