py123d_detection.torch.data.dataset

A PyTorch dataset reading 123D scenes straight into camera-based 3D detection batches.

One 123D frame becomes one sample: the rig’s images, the matrices that project the ego frame into each of them, and the boxes in the ego frame. No pickle, no mmdetection3d and no conversion step. Source names the logs and the dataset reads them.

The work is split by what it is about, and this class only puts the parts in order:

  • FrameIndex picks which frames, and how many.

  • BoxLoader gives a frame’s boxes, filtered, in the ego frame.

  • Augmentation makes the random draw for a training sample.

  • CameraLoader reads the rig’s images in network geometry.

The sample is the layout the PETR family expects:

img             (N_cam, 3, H, W)  uint8, zero-padded to the backbone's stride; the model normalises
img_shape       (2,)              (H, W) before padding
intrinsics      (N_cam, 4, 4)     including every crop, resize and flip applied to the image
extrinsics      (N_cam, 4, 4)     ego -> camera
imu2img         (N_cam, 4, 4)     ego -> pixels, i.e. intrinsics @ extrinsics
ego_pose        (4, 4)            ego -> world, and ego_pose_inv its inverse
cam_valid_mask  (N_cam,)          False where a camera had no image this frame
gt_bboxes_3d    (M, 9)            [x, y, z, w, l, h, yaw, vx, vy] in the ego frame
gt_labels_3d    (M,)              indices into the taxonomy's class_names

Coordinates are the ego (IMU) frame throughout, not the lidar frame: 123D defines the rig against the ego body, and a camera-only detector never needs the lidar’s. Yaw is measured from the ego x axis towards y, and velocity is the box’s ground-plane motion in that same frame.

Functions

assemble(cameras, boxes, ego_to_world, draw)

The tensors of one sample, with the bird's-eye augmentation applied to boxes and matrices.

Classes

Py123DDetectionDataset(source, taxonomy, rig)

Camera-based 3D detection samples from 123D logs.

class py123d_detection.torch.data.dataset.Py123DDetectionDataset(source, taxonomy, rig, images=None, augment=None, filters=None, compute_velocity=False, temporal=False, name=None, missing_camera='skip', num_frames=None, seed=None)[source]

Bases: Dataset

Camera-based 3D detection samples from 123D logs.

Parameters:
  • source (Source) – Which logs and at what frame rate. See Source.

  • taxonomy (Taxonomy) – Turns 123D labels into class names and ids, and merges riders onto their vehicles where a dataset boxes them separately.

  • rig (CameraRig) – Which cameras to read and which part of each image to keep.

  • images (Optional[ImagePipeline]) – The network input size and how images are brought to it.

  • augment (Optional[Augmentation]) – The random draw for training samples. None is the validation dataset.

  • filters (Optional[BoxFilters]) – Which boxes count. See BoxFilters.

  • compute_velocity (bool) – Derive box velocity from track positions over time. Needed for datasets that store none, such as Argoverse 2.

  • temporal (bool) – Add prev_exists to each sample, telling a temporal model whether the previous index is the same scene.

  • name (Optional[str]) – Label carried in img_metas and used when several datasets are mixed.

  • missing_camera (str) – What to do when a frame has no image for a camera. "skip" rejects the frame; "zero" substitutes a blank image and clears its cam_valid_mask entry.

  • num_frames (Optional[int]) – Serve this many frames, spread evenly over all logs. See FrameIndex.

  • seed (Optional[int]) – Seeds the augmentation generator. The data module reseeds it per worker and rank.

get(index, draw=None)[source]

One sample, or the next usable one.

A frame can be unusable, because a camera dropped out or every box was filtered away. Rather than returning nothing and breaking the batch, the next frame is tried. Scanning the whole dataset without success is an error worth raising.

Parameters:

draw (Optional[Draw]) – Use this augmentation instead of drawing one, to reproduce a sample exactly.

Return type:

Dict[str, Any]

reseed(*entropy)[source]

Restart the augmentation generator, e.g. from a worker’s seed and the trainer’s rank.

Return type:

None

draw()[source]

A training sample’s random draw, or the identity for validation.

Return type:

Draw

load(index, draw=None)[source]

Build the sample at exactly index, or None when that frame cannot produce one.

Return type:

Optional[Dict[str, Any]]

py123d_detection.torch.data.dataset.assemble(cameras, boxes, ego_to_world, draw)[source]

The tensors of one sample, with the bird’s-eye augmentation applied to boxes and matrices.

Return type:

Dict[str, Any]