py123d_detection.torch.data.collate¶
Batching samples whose rigs differ.
Mixing datasets means mixing camera counts: nuScenes has six, Argoverse seven, Waymo five. A
batch pads every sample up to the largest and carries cam_mask so a model can ignore what was
added. Ground truth stays a list, because the number of objects varies per frame and padding it
would invent boxes.
Padded projection matrices are the identity, never zeros. A zero 4x4 is singular, and a model that inverts or chains it gets NaN out of a camera that does not exist.
Module Attributes
Kept as lists: their length varies per sample, so stacking would need padding that means something. |
|
Stacked along a camera dimension that is padded up to the batch's widest rig. |
|
Entries of |
Functions
|
Collate samples from rigs of different sizes. |
- py123d_detection.torch.data.collate.PER_SAMPLE_KEYS = ('gt_bboxes_3d', 'gt_labels_3d', 'img_metas')¶
Kept as lists: their length varies per sample, so stacking would need padding that means something. A padded box is a false object.
- py123d_detection.torch.data.collate.PER_CAMERA_KEYS = ('img', 'intrinsics', 'extrinsics', 'imu2img', 'cam_valid_mask')¶
Stacked along a camera dimension that is padded up to the batch’s widest rig.
- py123d_detection.torch.data.collate.PER_CAMERA_METADATA = ('ori_shape', 'img_shape', 'pad_shape')¶
Entries of
img_metasholding one value per camera, extended alongside the tensors.
- py123d_detection.torch.data.collate.collate_rigs(batch)[source]¶
Collate samples from rigs of different sizes.
Adds two keys the samples do not have:
cam_mask(B, N)True where a camera is both present in that sample’s rig and had an image. This is the one a model should mask attention with.
num_cams(B,)How many cameras each sample’s own rig has, before padding.