nncore.ops

Bbox

nncore.ops.bbox.bbox_area(bboxes)[source]

Compute the areas of bounding boxes.

Parameters:

bboxes (nn.Tensor[N, 4]) – Bounding boxes to be computed. They are expected to be in (x1, y1, x2, y2) format.

Returns:

The computed areas.

Return type:

nn.Tensor[N]

nncore.ops.bbox.bbox_intersection(bboxes1, bboxes2, aligned=False)[source]

Compute the intersections among bounding boxes.

Parameters:
  • bboxes1 (nn.Tensor[N, 4]) – Bounding boxes to be computed. They are expected to be in (x1, y1, x2, y2) format.

  • bboxes2 (nn.Tensor[M, 4]) – Bounding boxes to be computed. They are expected to be in (x1, y1, x2, y2) format.

  • aligned (bool, optional) – Whether to only compute the intersections among aligned bounding boxes. Default: False.

Returns:

The computed intersection values.

Return type:

nn.Tensor[N] | nn.Tensor[N, M]

nncore.ops.bbox.bbox_iou(bboxes1, bboxes2, aligned=False)[source]

Compute the intersection-over-unions (IoUs) among bounding boxes.

Parameters:
  • bboxes1 (nn.Tensor[N, 4]) – Bounding boxes to be computed. They are expected to be in (x1, y1, x2, y2) format.

  • bboxes2 (nn.Tensor[M, 4]) – Bounding boxes to be computed. They are expected to be in (x1, y1, x2, y2) format.

  • aligned (bool, optional) – Whether to only compute the IoU among aligned bounding boxes. Default: False.

Returns:

The computed pairwise IoU values.

Return type:

nn.Tensor[N] | nn.Tensor[N, M]

nncore.ops.bbox.bbox_iof(bboxes1, bboxes2, aligned=False)[source]

Compute the intersection-over-foregrounds (IoFs) among bounding boxes.

Parameters:
  • bboxes1 (nn.Tensor[N, 4]) – Bounding boxes to be computed. They are expected to be in (x1, y1, x2, y2) format.

  • bboxes2 (nn.Tensor[M, 4]) – Bounding boxes to be computed. They are expected to be in (x1, y1, x2, y2) format.

  • aligned (bool, optional) – Whether to only compute the IoF among aligned bounding boxes. Default: False.

Returns:

The computed pairwise IoF values.

Return type:

nn.Tensor[N] | nn.Tensor[N, M]

nncore.ops.bbox.remove_small_bboxes(bboxes, min_size)[source]

Remove bounding boxes which contains at least one side smaller than the minimum size.

Parameters:
  • bboxes (nn.Tensor[N, 4]) – Bounding boxes to be computed. They are expected to be in (x1, y1, x2, y2) format.

  • min_size (float) – The minimum size of bounding boxes.

Returns:

Indices of the bounding boxes that have both sides larger than min_size.

Return type:

nn.Tensor[K]

Temporal

nncore.ops.temporal.temporal_area(windows)[source]

Compute the areas of temporal windows.

Parameters:

windows (nn.Tensor[N, 2]) – Temporal windows to be computed. They are expected to be in (start, end) format.

Returns:

The computed areas.

Return type:

nn.Tensor[N]

nncore.ops.temporal.temporal_intersection(windows1, windows2, aligned=False)[source]

Compute the intersections among temporal windows.

Parameters:
  • windows1 (nn.Tensor[N, 2]) – Temporal windows to be computed. They are expected to be in (start, end) format.

  • windows2 (nn.Tensor[M, 2]) – Temporal windows to be computed. They are expected to be in (start, end) format.

  • aligned (bool, optional) – Whether to only compute the intersections among aligned temporal windows. Default: False.

Returns:

The computed intersection values.

Return type:

nn.Tensor[N] | nn.Tensor[N, M]

nncore.ops.temporal.temporal_iou(windows1, windows2, aligned=False)[source]

Compute the intersection-over-unions (IoUs) among temporal windows.

Parameters:
  • windows1 (nn.Tensor[N, 2]) – Temporal windows to be computed. They are expected to be in (start, end) format.

  • windows2 (nn.Tensor[M, 2]) – Temporal windows to be computed. They are expected to be in (start, end) format.

  • aligned (bool, optional) – Whether to only compute the IoU among aligned temporal windows. Default: False.

Returns:

The computed pairwise IoU values.

Return type:

nn.Tensor[N] | nn.Tensor[N, M]

nncore.ops.temporal.temporal_iof(windows1, windows2, aligned=False)[source]

Compute the intersection-over-foregrounds (IoFs) among temporal windows.

Parameters:
  • windows1 (nn.Tensor[N, 2]) – Temporal windows to be computed. They are expected to be in (start, end) format.

  • windows2 (nn.Tensor[M, 2]) – Temporal windows to be computed. They are expected to be in (start, end) format.

  • aligned (bool, optional) – Whether to only compute the IoF among aligned temporal windows. Default: False.

Returns:

The computed pairwise IoF values.

Return type:

nn.Tensor[N] | nn.Tensor[N, M]

Data