py123d_detection.torch.models.common.backbone¶
The image backbone both detectors run over a camera rig.
A ResNet-50 or ResNet-101 with deformable convolutions in its last two stages, feeding PETR’s CPFPN rather than a standard FPN. This is the configuration the PETR paper reports and the thesis trained, so it is kept as it is rather than generalised.
Three things here exist for memory and for distributed training rather than for accuracy. Gradient
checkpointing is applied by wrapping each ResNet block’s forward, which recomputes activations
instead of storing them. BatchNorm is frozen, as official PETR’s requires_grad=False config
does, because a batch of two frames is too small to estimate statistics from. And early stages can
be frozen outright, which is also what keeps DDP from complaining about parameters that never
receive a gradient.
Classes
|
PETR's feature pyramid, which is a standard FPN with most of the smoothing left out. |
|
A deformable convolution that learns its own sampling offsets. |
|
Feature extractor for 3D object detection. |
- class py123d_detection.torch.models.common.backbone.DCNWrapper(in_channels, out_channels, stride, padding, dilation, groups, bias)[source]¶
Bases:
ModuleA deformable convolution that learns its own sampling offsets.
An ordinary convolution reads a fixed grid of neighbours. This one predicts a per-pixel offset and a per-pixel weight for each tap first, so the kernel can follow an object rather than a square. PETR uses it in the backbone’s last two stages, where the features are coarse enough that a rigid grid costs accuracy.
- class py123d_detection.torch.models.common.backbone.CPFPN(in_channels, out_channels, num_outs, start_level=0, end_level=-1, add_extra_convs=False)[source]¶
Bases:
ModulePETR’s feature pyramid, which is a standard FPN with most of the smoothing left out.
A standard FPN runs a 3x3 convolution over every level after the top-down merge. This one does it for the highest-resolution level only; the rest are the 1x1 lateral outputs as they come. PETR ships it this way (
cp_fpn.pyin its mmdet3d plugin) and the weights expect it, so the missing convolutions are not an omission.
- class py123d_detection.torch.models.common.backbone.FeatureExtractor(out_channels=256, return_layers=None, backbone='resnet101', train_backbone=True, frozen_stages=-1, norm_eval=True, with_cp=True)[source]¶
Bases:
ModuleFeature extractor for 3D object detection.
The image backbone: a ResNet with deformable convolutions in its last two stages, feeding PETR’s CPFPN. This is what the official PETR configuration builds.