Skip to content

corner

Corner loss of the box-refinement heads (PointRCNN).

Classes:

CornerLoss [source] ΒΆ

CornerLoss(
    beta: float = 1.0,
    reduction: Literal["none", "sum", "mean"] = "mean",
)

Bases: Module

Module form of corner_loss.

Parameters:

  • beta (float, default: 1.0 ) –

    Smooth-\(L_1\) transition point.

  • reduction (Literal['none', 'sum', 'mean'], default: 'mean' ) –

    "none" returns the per-box loss, "sum" its sum, "mean" its mean.

Example
import torch
from torch_pointcloud.losses import CornerLoss

criterion = CornerLoss()
box = torch.tensor([[0.0, 0.0, 0.0, 4.0, 2.0, 1.5, 0.3]])
criterion(box, box).item()  # 0.0

Methods:

  • forward –

    Compute the corner loss between matched boxes pred_boxes \((N, 7)\) and gt_boxes \((N, 7)\).

forward [source] ΒΆ

forward(pred_boxes: Tensor, gt_boxes: Tensor) -> Tensor

Compute the corner loss between matched boxes pred_boxes \((N, 7)\) and gt_boxes \((N, 7)\).

corner_loss [source] ΒΆ

corner_loss(
    pred_boxes: Tensor,
    gt_boxes: Tensor,
    *,
    beta: float = 1.0,
) -> Tensor

Per-box mean smooth-\(L_1\) distance between the eight corners of two box sets, robust to the heading flip.

The corner regularization of PointRCNN: 3D Object Proposal Generation and Detection from Point Cloud (Shi et al., 2019): each predicted corner is compared with the matching corner of the ground-truth box and of that box rotated by \(\pi\), and the closer of the two distances is penalized, so a heading off by half a turn is not punished as a position error.

Parameters:

  • pred_boxes (Tensor) –

    Predicted boxes \((c_x, c_y, c_z, d_x, d_y, d_z, \theta)\), shape \((N, 7)\).

  • gt_boxes (Tensor) –

    Matched ground-truth boxes, shape \((N, 7)\).

  • beta (float, default: 1.0 ) –

    Smooth-\(L_1\) transition point.

Returns:

  • Tensor –

    The per-box loss, shape \((N,)\).

Shape
  • pred_boxes: \((N, 7)\)
  • gt_boxes: \((N, 7)\)
  • output: \((N,)\)
Example
>>> box = torch.tensor([[0.0, 0.0, 0.0, 4.0, 2.0, 1.5, 0.3]])
>>> corner_loss(box, box).tolist()
[0.0]
>>> flipped = box.clone()
>>> flipped[:, 6] += math.pi
>>> corner_loss(box, flipped).abs().max().item() < 1e-5
True