Skip to content

centerpoint

Losses of the center-based detection heads, dense (CenterHead) and fully sparse (VoxelNeXtHead).

Both supervise the heatmap with gaussian_focal_loss and the gathered regression codes with a masked, code-weighted \(L_1\); the dense targets come from draw_heatmap_targets.

Classes:

CenterHeadLoss [source] ΒΆ

CenterHeadLoss(
    num_classes: int,
    *,
    point_cloud_range: Sequence[float],
    voxel_size: Sequence[float],
    feature_map_stride: int,
    code_weights: Sequence[float],
    cls_weight: float = 1.0,
    loc_weight: float = 0.25,
    iou_weight: float = 0.0,
    gaussian_overlap: float = 0.1,
    min_radius: int = 2,
    num_max_objs: int = 500,
)

Bases: Module

Loss of the dense CenterHead (CenterPoint, Voxel Mamba).

Reference: Center-based 3D Object Detection and Tracking (Yin et al., 2021).

Ground-truth boxes are splatted onto a per-class BEV Gaussian heatmap and their regression code (sub-cell center offset, \(z\), log extents and \((\cos\theta, \sin\theta)\)) is recorded at each peak cell. The heatmap is supervised by the penalty-reduced center focal loss and the regression maps by a masked, code-weighted \(L_1\) read back at those cells. When the head emits an iou map an optional \(L_1\) term regresses it toward the 3D IoU (rescaled to \([-1, 1]\)) between the decoded prediction and its matched box.

Parameters:

  • num_classes (int) –

    Number of heatmap channels.

  • point_cloud_range (Sequence[float]) –

    Range \((x_\min, y_\min, z_\min, x_\max, y_\max, z_\max)\).

  • voxel_size (Sequence[float]) –

    Voxel size \((v_x, v_y, v_z)\).

  • feature_map_stride (int) –

    Stride from the voxel grid to the BEV feature map.

  • code_weights (Sequence[float]) –

    Per-code regression weight, length \(8\) (the head predicts no velocity codes).

  • cls_weight (float, default: 1.0 ) –

    Multiplier on the heatmap focal loss.

  • loc_weight (float, default: 0.25 ) –

    Multiplier on the summed regression loss.

  • iou_weight (float, default: 0.0 ) –

    Multiplier on the optional IoU-branch loss (\(0\) disables it).

  • gaussian_overlap (float, default: 0.1 ) –

    Min-overlap passed to the Gaussian-radius solver.

  • min_radius (int, default: 2 ) –

    Lower clamp on the integer splat radius.

  • num_max_objs (int, default: 500 ) –

    Per-scene object-target capacity.

Methods:

  • forward –

    Compute the dense center loss and its terms.

forward [source] ΒΆ

forward(
    output: CenterHeadOutput, data: Dict[str, Any]
) -> Dict[str, Tensor]

Compute the dense center loss and its terms.

Parameters:

  • output (CenterHeadOutput) –

    Head maps heatmap \((B, C, H, W)\), center \((B, 2, H, W)\), center_z \((B, 1, H, W)\), dim \((B, 3, H, W)\), rot \((B, 2, H, W)\) and optionally iou \((B, 1, H, W)\).

  • data (Dict[str, Any]) –

    Packed GT (DataKeys.BOX, DataKeys.LABEL, DataKeys.BATCH_BOX).

Returns:

  • Dict[str, Tensor] –

    A dict with the scalar loss and detached heatmap_loss, box_loss (and iou_loss when enabled).

VoxelNeXtHeadLoss [source] ΒΆ

VoxelNeXtHeadLoss(
    class_groups: Sequence[Sequence[int]],
    *,
    point_cloud_range: Sequence[float],
    voxel_size: Sequence[float],
    feature_map_stride: int,
    code_weights: Sequence[float],
    cls_weight: float = 1.0,
    loc_weight: float = 0.25,
    gaussian_overlap: float = 0.1,
    min_radius: int = 2,
    num_max_objs: int = 500,
)

Bases: Module

Loss of the fully sparse VoxelNeXtHead.

Reference: VoxelNeXt: Fully Sparse VoxelNet for 3D Object Detection and Tracking (Chen et al., 2023).

The head predicts CenterPoint-style attributes directly on the occupied BEV voxels rather than a dense map, so targets are drawn only at those voxels: the per-class heatmap is a Gaussian in squared voxel distance and each object's regression code is anchored to its nearest occupied voxel. The heatmap is supervised by the penalty-reduced center focal loss and the gathered regression rows by a masked, code-weighted \(L_1\). Classes are split into groups, one sparse head each.

Parameters:

  • class_groups (Sequence[Sequence[int]]) –

    Zero-based global class-index groups, one per head (e.g. [[0], [1, 2], ...]).

  • point_cloud_range (Sequence[float]) –

    Range \((x_\min, y_\min, z_\min, x_\max, y_\max, z_\max)\).

  • voxel_size (Sequence[float]) –

    Voxel size \((v_x, v_y, v_z)\).

  • feature_map_stride (int) –

    Stride from the voxel grid to the BEV feature map.

  • code_weights (Sequence[float]) –

    Per-code regression weight, length \(8 + \text{extra}\) (e.g. \(10\) with velocity).

  • cls_weight (float, default: 1.0 ) –

    Multiplier on the heatmap focal loss.

  • loc_weight (float, default: 0.25 ) –

    Multiplier on the summed regression loss.

  • gaussian_overlap (float, default: 0.1 ) –

    Min-overlap passed to the Gaussian-radius solver.

  • min_radius (int, default: 2 ) –

    Lower clamp on the integer splat radius.

  • num_max_objs (int, default: 500 ) –

    Per-scene object-target capacity.

Methods:

  • forward –

    Compute the sparse center loss summed over class groups.

forward [source] ΒΆ

forward(
    output: VoxelNeXtHeadOutput, data: Dict[str, Any]
) -> Dict[str, Tensor]

Compute the sparse center loss summed over class groups.

Parameters:

  • output (VoxelNeXtHeadOutput) –

    A VoxelNeXtHeadOutput: per-group lists hm \((V, n_g)\), center \((V, 2)\), center_z \((V, 1)\), dim \((V, 3)\), rot \((V, 2)\), vel \((V, 2)\) and shared voxel_indices \((V, 3)\) with columns \((\text{batch}, y, x)\).

  • data (Dict[str, Any]) –

    Packed GT (DataKeys.BOX, DataKeys.LABEL, DataKeys.BATCH_BOX).

Returns:

  • Dict[str, Tensor] –

    A dict with the scalar loss and detached heatmap_loss, box_loss.