Skip to main content

apairo

PyPI Python versions CI License: MIT Docs DOI Website

Unified Python loader for robotics sensor datasets — one API across synchronous and asynchronous layouts, with built-in preprocessing, filtering, and dataset composition.

All data is returned as numpy.ndarray. Convert to the framework of your choice.

No loading overhead. apairo loads the same bytes at the same throughput as a hand-rolled loader — see apairo_benchmarks for the head-to-head proof.


Installation

pip install apairo

Optional extras:

pip install apairo[vision]   # Image loading (Pillow)
pip install apairo[zarr]     # Zarr channels
pip install apairo[hdf5]     # HDF5 containers (h5py)
pip install apairo[video]    # Video channels: MP4, MKV... (PyAV)
pip install apairo[tartan]   # A standard dataset: also rellis, goose, semantic-kitti, tum, euroc, kuka
pip install apairo[ros]      # The ecosystem: also transform, preprocess, visu

Requires Python ≥ 3.11.

ROS bags, transforms, preprocessors and viewers are separate packages on PyPI, also installed by those extras: see Ecosystem for what each does and its install line.


Quickstart

import apairo

ds = apairo.SemanticKittiDataset("/data/semantic_kitti", keys=["lidar", "labels"])
sample = ds[0]
# sample.data["lidar"]   -> np.ndarray (N, 4)  float32  [x, y, z, intensity]
# sample.data["labels"]  -> np.ndarray (N,)    int64

Supported datasets

Class Layout Modalities
SemanticKittiDataset synchronous lidar, labels
Rellis3DDataset synchronous lidar, labels, poses
Goose3DDataset synchronous lidar, labels
RawDataset asynchronous any channels — declared in .apairo/channels.yaml
TartanKittiDataset asynchronous any TartanDrive v2 channel

RawDataset is the profile-free loader for the asynchronous layout: it takes its channels — and their format (npy, npys, bin, img, zarr, pcd, csv, hdf5, video, or a plugin's) — entirely from .apairo/channels.yaml, so it loads any such dataset, including the output of apairo_ros, with no code change.


Bring your own dataset — keys in the filenames

Point apairo at a directory of files and it loads. When each frame's alignment clock is encoded in its filename — a timestamp, an index — declare it in channels.yaml; apairo parses the key in memory at read time and never writes into your data:

# .apairo/channels.yaml
version: 1
channels:
  camera: {loader: img, key: {name: 'frame\d+-(\d+)_(\d+)'}}   # timestamp from frame000123-1581624652_750.jpg
  labels: {loader: img, key: {name: 'frame\d+-(\d+)_(\d+)'}}   # same clock; a sparse subset of frames
ds   = apairo.RawDataset(seq_dir, keys=["camera", "labels"])
view = ds.synchronize(reference="camera", method="nearest", tolerance=0.0)  # the camera frames that have a label
  • key: {name: <regex>} parses the key from the filename stem (scale: [...] for an explicit unit combine); key: {file: <name>} reads it from a sidecar.
  • A separate order: controls enumeration; a subclass can hand in _key_providers / _order_providers callables for anything the DSL can't express.
  • No key → the channel's timestamps.txt, or a clock borrowed with timestamps_from. Fully additive, opt-in, read-only.

This turns the Rellis-3D camera (2847 frames @ 10 Hz, plus 1200 half-rate image-labels) into two lines of channels.yaml — no subclass, no filename→timestamps.txt transcode. See the Bring your own dataset guide.


Command line

Installing apairo provides the apairo command to inspect and initialize datasets from the terminal:

# Write/repair the .apairo sidecars by scanning a directory (root-aware, idempotent)
apairo init /data/my_dataset

# Show sequences, channels (tracked + untracked), event count and any issues
apairo status /data/my_dataset           # add --json for machine output

apairo init reconstructs the .apairo files for data laid out before they existed (e.g. an older extraction) — no re-extraction needed — and the result loads directly with RawDataset. See Command Line for the full reference.


Pipeline

apairo provides a composable set of operations that chain together — each returns a full dataset:

from apairo import Rellis3DDataset, FramePreprocessor
from torch.utils.data import DataLoader
import numpy as np

# 1. Preprocess — run once, persisted in .apairo, reloaded transparently
class TravLabel(FramePreprocessor):
    output_key = "trav_gt";  output_loader = "npys"
    input_keys = ["labels"]; timestamps_from = "lidar"; sources = ["labels"]
    def __call__(self, sample): return (sample.data["labels"] < 10).astype(np.uint8)

ds = Rellis3DDataset(root, keys=["lidar", "labels"])
ds.run_preprocess(TravLabel())

# 2. Cache an expensive derived channel — computed once, served from RAM
ds = ds.transform("lidar", expensive_ground_prior, output="ground_prior")
ds_prior = ds.select(["ground_prior"]).cache()

# 3. Build train split — filter, join cached prior, apply augmentation
valid = np.load("cache/valid_indices.npy")
ds_train = (
    Rellis3DDataset(root, keys=["lidar", "trav_gt"])
    .filter(valid)
    .join(ds_prior)
    .transform("lidar", RangeFilter(max=50.0))
)

# 4. Drop into DataLoader — no adapter needed
loader = DataLoader(ds_train, batch_size=8, shuffle=True, collate_fn=my_collate)

See examples/ for complete runnable pipelines.


Preprocessing

Define a FramePreprocessor or SequencePreprocessor, run it once — apairo persists the output and reloads it transparently on subsequent runs.

from apairo.preprocess import FramePreprocessor

class TravLabel(FramePreprocessor):
    output_key      = "trav_label"
    output_loader   = "npys"
    input_keys      = ["labels"]
    timestamps_from = "labels"
    sources         = ["labels"]

    def __call__(self, sample) -> np.ndarray:
        return (sample.data["labels"] < 10).astype(np.uint8)

ds = apairo.Goose3DDataset("/data/goose", keys=["lidar", "labels"])
ds.run_preprocess(TravLabel())

See apairo_preprocess for a collection of ready-made preprocessors.


Transforms

Apply callables at access time — no disk writes.

# Per-channel
ds = ds.transform("lidar", RangeFilter(max=50.0))

# Sample-level — consistent mask across aligned channels
def sync_filter(sample):
    mask = np.linalg.norm(sample.data["lidar"][:, :3], axis=1) < 50.0
    sample.data["lidar"]  = sample.data["lidar"][mask]
    sample.data["labels"] = sample.data["labels"][mask]
    return sample

ds = ds.transform(sync_filter)

See apairo_transform for a collection of ready-made transforms.


Filtering

filter() returns a dataset view restricted to frames that pass a predicate. Sweep once, persist the indices, reload without I/O cost on subsequent runs:

# Compute and save
view = ds.filter("trav_gt", lambda gt: (gt == 1).sum() >= 50)
np.save("cache/valid.npy", view.indices)

# Reload — no sweep
view = ds.filter(np.load("cache/valid.npy"))

Select & cache

select(keys) narrows a dataset to a subset of channels. cache() materialises it in RAM. Together they let you cache only the channels worth caching:

ds = Rellis3DDataset(root, keys=["lidar"])
ds = ds.transform("lidar", expensive_ground_prior, output="ground_prior")

# Compute once, store in RAM
ds_prior = ds.select(["ground_prior"]).cache()

# Reuse across training runs — prior served from RAM, base channels from disk
base = Rellis3DDataset(root, keys=["lidar", "labels"])
ds_v1 = base.join(ds_prior).transform(augment_v1)
ds_v2 = base.join(ds_prior).transform(augment_v2)

Asynchronous datasets — synchronize()

Asynchronous datasets (multi-rate sensor rigs) expose a timestamp-ordered event timeline: ds[i] is one event from one sensor. To get complete multi-channel frames, resample onto a reference clock:

ds = apairo.TartanKittiDataset(seq_dir, keys=["velodyne_0", "image_left", "cmd"])

ds_sync = ds.synchronize(
    reference="velodyne_0",   # default: lowest-frequency channel
    method="previous",        # "previous" (zero-order hold), "next" or "nearest"
    tolerance=0.05,           # drop frames with no match within ±50 ms
)

ds_sync[0].data   # {"velodyne_0": ..., "image_left": ..., "cmd": ...}

The result is a synchronous view — random access, shuffling, and the whole chaining API (filter, select, cache, join, DataLoader) work unchanged. Matching is a pure index computation; no data is read until access.


Combining datasets

# ConcatDataset — frame axis (different recording sessions)
combined = apairo.ConcatDataset([ds_session1, ds_session2])

# ZipDataset — channel axis (same frames, different modalities)
combined = apairo.ZipDataset(ds_base, ds_prior)
# or: ds_base.join(ds_prior)

# Built-in splits
ds_train = apairo.Rellis3DDataset(root, keys=["lidar", "labels"]).split("train")
ds_val   = apairo.Rellis3DDataset(root, keys=["lidar", "labels"]).split("val")

Inference — the training chain, deployed

deployed = train.inference(["trav_pred"])   # prunes what the output does not need, drops augmentations
print(deployed.summary)                     # kept / removed / flagged (non-causal sync, opaque steps)
deployed.on(other_recording)                # the same chain on another source
deployed.save("trav_chain.json")            # a JSON declaration beside the checkpoint

See Inference & Deployment.


Extending apairo

Add a new synchronous dataset with a YAML profile and a minimal subclass. See documentation for the full guide.


Contributing

apairo is one repository of a small ecosystem (apairo_transform, apairo_preprocess, apairo_ros, apairo_visu). Where a change belongs, the design invariants, and the dev workflow are documented in CONTRIBUTING.md.


License

MIT

Metadata

Release files for apairo 0.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for apairo 0.11.0
File Size Uploaded Provenance Actions
apairo-0.11.0.tar.gz 214.3 kB With provenance Details for apairo-0.11.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for apairo 0.11.0
File Interpreter ABI Platform Actions
apairo-0.11.0-py3-none-any.whl Python 3 none any Details for apairo-0.11.0-py3-none-any.whl

Total release size: 457.1 kB

Release files / apairo-0.11.0.tar.gz

Download URL apairo-0.11.0.tar.gz
Size 214.3 kB
Tags Source
SHA-256 checksum
How to use checksums
20c4938a8f53bbab92f67aa0a3731d1a792dcb1d4b2bd1c9bc076faf7a6fb421
BLAKE2b-256 checksum
How to use checksums
bd16047290528c4e6cb2d351711229e3d3eb4342b0950db38bf7961f7ec9b8da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Release files / apairo-0.11.0-py3-none-any.whl

Download URL apairo-0.11.0-py3-none-any.whl
Size 242.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d578217979559278fee31dbc80b4d344f75b4d050da421d6c9bcec8aafcb74ae
BLAKE2b-256 checksum
How to use checksums
ac1f8e2b6b64c7aa7ffe1e6d71d16ec41ef3669d677841bb35c17c018d098b06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Security for apairo 0.11.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for apairo-0.11.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page