Extending the Loader¶
The RPXDataset class is the only
entry point for turning a manifest JSON file into a stream of
Sample batches. It dispatches to
per-task _load_* methods based on the manifest's task field. To
add support for a brand-new modality or task, you either:
- Add new fields to an existing task's sample entries — nothing
to change in the loader if the new fields are optional and your
adapter picks them out of
sample.metadata. - Add a new task type — write a new
_load_<task>method and add a dispatch branch in_load_ground_truth.
Option 1: passthrough via metadata¶
The loader already attaches arbitrary extras to sample.metadata.
For example, pair tasks (keypoint matching, relative pose) use this
channel to ship a second RGB frame:
# rpx_benchmark/loader.py excerpt
if "rgb_b" in entry:
metadata["rgb_b"] = self._load_rgb(entry["rgb_b"])
Any custom field in your manifest that the loader doesn't recognise
will be left alone in entry — you can reach it from your
InputAdapter via sample.metadata (if you stash it there) or via
sample.ground_truth (if it's part of a task-specific dataclass).
Option 2: a whole new task¶
- Add the enum value to
TaskTypeinrpx_benchmark/api.py. - Add the ground-truth dataclass next to the existing ones in
api.py. Keep it simple — numpy arrays, enums, strings. -
Write
_load_<your_task>inrpx_benchmark/loader.py: -
Dispatch from
_load_ground_truth: -
Raise
ManifestErrorfrom the new loader with ahintwhenever the manifest field shape is wrong. Every built-in_load_*method does this. - Add at least one test under
tests/test_loader_gt_paths.pythat builds a tiny synthetic fixture and verifies the returned dataclass shape.
File-level helpers to reuse¶
self._load_rgb(path)→uint8 H×W×3self._load_depth(path)→float32 H×Win metres (16-bit PNG mm input)self._load_mask(path)→int32 H×Winstance IDsself._load_pose(path)→float64 4×4SE(3) from a T265 NPZself._load_gray(path)→uint8 H×W(fisheye-style)self._load_boxes(path)→(N×4 float32, list[str])self._load_array_or_inline(value)→ accepts a path (.npy,.json) or an inline list/tuple
All of them resolve paths via self._resolve(relative) which
joins the dataset root with the (possibly absolute) input.