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:
FrameIndexpicks which frames, and how many.BoxLoadergives a frame’s boxes, filtered, in the ego frame.Augmentationmakes the random draw for a training sample.CameraLoaderreads 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
|
The tensors of one sample, with the bird's-eye augmentation applied to boxes and matrices. |
Classes
|
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:
DatasetCamera-based 3D detection samples from 123D logs.
- Parameters:
source (
Source) – Which logs and at what frame rate. SeeSource.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.Noneis the validation dataset.filters (
Optional[BoxFilters]) – Which boxes count. SeeBoxFilters.compute_velocity (
bool) – Derive box velocity from track positions over time. Needed for datasets that store none, such as Argoverse 2.temporal (
bool) – Addprev_existsto each sample, telling a temporal model whether the previous index is the same scene.name (
Optional[str]) – Label carried inimg_metasand 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 itscam_valid_maskentry.num_frames (
Optional[int]) – Serve this many frames, spread evenly over all logs. SeeFrameIndex.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.