API Reference
Synchronous datasets
ProfiledDataset
apairo.core.profiled_dataset.ProfiledDataset
Bases: SynchronousDataset, ConfigurableDataset
Synchronous dataset driven by a YAML structural profile.
Subclasses declare a _profile class attribute pointing to a YAML file
(relative to apairo/dataset/profiles/ or an absolute path). The profile
describes the directory layout, file extensions, dtypes, and any type
transformations. All file discovery, loading, split filtering, and derived
key resolution are handled automatically.
Example
Minimal subclass::
class MyDataset(ProfiledDataset):
_profile = "my_dataset.yaml"
Usage::
ds = MyDataset("/data/my_dataset", keys=["lidar", "labels"], split="train")
sample = ds[0]
# sample.data["lidar"] -> np.ndarray
# sample.data["labels"] -> np.ndarray
Attributes:
| Name | Type | Description |
|---|---|---|
available_keys |
frozenset[str]
|
Frozenset of key names declared in the profile. Populated at class definition time from the YAML file. |
See Also
YAML Profiles <https://apairo-robotics.github.io/apairo/datasets/yaml-profiles/>_
for the full profile specification.
Source code in apairo/core/profiled_dataset.py
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 | |
frame_sequence_ids
cached
property
Sequence ID for every frame, indexed by global frame index.
Returns a string array of shape (len(self),) where
frame_sequence_ids[i] is the sequence ID that frame i belongs
to. Combined with :attr:FilteredView.indices, this lets you split a
pre-filtered dataset by sequence without a second disk sweep::
ds_filtered = ds.filter("trav_gt", HasMinPositives(min_pos))
seq_ids = ds.frame_sequence_ids[ds_filtered.indices]
for train_seqs, val_seqs in folds:
train_idx = np.where(np.isin(seq_ids, train_seqs))[0]
val_idx = np.where(np.isin(seq_ids, val_seqs))[0]
ds_train = ds_filtered.filter(train_idx)
ds_val = ds_filtered.filter(val_idx)
frame_stems
cached
property
Filename stem for every frame, indexed by global frame index.
init
classmethod
init(directory: str | Path, *, merge: bool = False, overwrite: bool = False, name: str | None = None) -> Path
Write .apairo/channels.yaml from the dataset profile.
Maps the profile's canonical channel names onto the raw directories
present on disk (e.g. os1_cloud_node_kitti_bin -> lidar). One
config at directory covers every sequence the profile spans.
Preprocessed channels are not auto-registered: after init, inspect
:meth:unregistered_channels (the CLI prints them) and declare the ones
you want with :meth:register_channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
Dataset root directory. |
required |
merge
|
bool
|
Add profile channels to an existing config, leaving channels already declared untouched. |
False
|
overwrite
|
bool
|
Discard any existing |
False
|
name
|
str | None
|
Dataset name recorded in the root manifest
( |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path of the written |
Path
|
|
Source code in apairo/core/profiled_dataset.py
unregistered_channels
classmethod
Directories that look like channels but are in neither the profile nor the current config -- candidate preprocessed channels.
Best-effort and report-only: returns {name: loader} for sub-directories
at the profile's modality depth that hold loadable files. Nothing is
registered; declare the ones you want with :meth:register_channel.
Source code in apairo/core/profiled_dataset.py
remove_channel
classmethod
Remove a channel, profile-aware (overrides
:meth:ConfigurableDataset.remove_channel).
A profiled dataset keeps a single channels.yaml at the root but stores
each channel's data per sequence (e.g. Rellis-3D/<seq>/<modality>),
so the generic root/key deletion would miss the sequence directories.
This drops the (root) declaration and, with data=True, deletes the
channel's storage in every sequence the profile spans.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
Dataset root directory. |
required |
key
|
str
|
Channel name to remove (the profile's canonical name). |
required |
data
|
bool
|
Also delete the channel's per-sequence data (destructive). |
False
|
Source code in apairo/core/profiled_dataset.py
inventory
classmethod
Structural self-description from a root path, without loading data.
The path-based form of :meth:describe: builds the profile geometry
(no file discovery, no loaders) and reports identity, sequences, channel
layout, splits and calibration. Tolerant -- it describes a partial
dataset without raising, unlike the constructor. See :meth:describe
for the returned schema.
Source code in apairo/core/profiled_dataset.py
describe
Describe this dataset's structure -- identity, sequences, channels.
Returns a structured dict (and prints a human-readable summary). Cross-
references the profile's declared modalities with what is on disk to show
which raw channels are present or missing and where each lives, plus any
registered preprocessed channels. Per-frame facts (counts, shapes) are
intentionally not here -- read them from the loaded dataset
(len(ds), ds[i].data[key].shape).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence_id
|
str | None
|
Optional identifier used as the printed display label only. Channel availability is dataset-wide. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
``{"class", "name", "root", "layout": {"fixed": [...]}, |
dict
|
"sequences": [...], "splits": [...], "calibration": [...], |
dict
|
"raw": {"present": [...], "missing": [...], "channels": {key: {...}}}, |
dict
|
"preprocess": {key: meta}}`` |
Example::
ds = Rellis3DDataset("/data/RELLIS")
ds.describe("00000")
Source code in apairo/core/profiled_dataset.py
split
Return a new dataset instance filtered to the named split.
This re-instantiates the dataset, so it starts with a clean pipeline: any
registered transform() is intentionally NOT carried over. To split
mid-chain while keeping transforms, use :meth:filter_split instead.
Source code in apairo/core/profiled_dataset.py
filter_split
Return a FilteredView restricted to the named predefined split.
Applies the split without re-instantiating the dataset — registered
transforms are preserved. Replaces :meth:split for use mid-chain::
ds.transform("lidar", RobotFilter())
ds_train = ds.filter_split("train") # transforms kept
Works for both LST-based splits (SemanticKITTI/Rellis) and directory-layer splits (GOOSE), so there is a transform-preserving split for every dataset.
Source code in apairo/core/profiled_dataset.py
SynchronousDataset
apairo.core.synchronous_dataset.SynchronousDataset
Bases: AbstractDataset
Base class for datasets where index i returns a complete synchronous frame.
All modalities at index i are co-captured -- one row is one sample across
every channel, no interleaving. That co-capture is what synchronous means;
it is independent of whether the frame carries a timestamp. Random access and
standard PyTorch DataLoader shuffling work without any additional wrappers.
A synchronous dataset may still expose a shared per-frame clock in
:attr:timestamps (one entry per global frame, so sample.timestamp is
that frame's tick); it defaults to None -- clockless -- and subclasses
populate it when the frames carry a timestamp.
Subclasses must implement __len__ and _load.
For new synchronous datasets, prefer extending
:class:~apairo.core.profiled_dataset.ProfiledDataset with a YAML profile
rather than subclassing this directly.
Attributes:
| Name | Type | Description |
|---|---|---|
synchronous |
Always |
|
timestamps |
dict | ndarray | None
|
The shared per-frame clock array, or |
Source code in apairo/core/synchronous_dataset.py
SemanticKittiDataset
apairo.dataset.semantic_kitti.SemanticKittiDataset
Bases: ProfiledDataset
SemanticKITTI dataset -- driving LiDAR with dense semantic labels.
Keys: lidar (float32, shape (N, 4)), labels (int64, lower 16 bits = semantic class).
Example::
ds = SemanticKittiDataset("/data/kitti/dataset", keys=["lidar", "labels"])
sample = ds[0]
# sample.data["lidar"] -> np.ndarray (N, 4)
# sample.data["labels"] -> np.ndarray (N,)
Source code in apairo/dataset/semantic_kitti/dataset.py
Goose3DDataset
apairo.dataset.goose.Goose3DDataset
Bases: ProfiledDataset
GOOSE 3D dataset -- outdoor off-road LiDAR with traversability labels.
Keys: lidar (float32, shape (N, 4)), labels (int64).
Split: "train", "val", or "test".
Example::
ds = Goose3DDataset("/data/GOOSE_3D", keys=["lidar", "labels"], split="train")
sample = ds[0]
# sample.data["lidar"] -> np.ndarray (N, 4)
# sample.data["labels"] -> np.ndarray (N,)
Source code in apairo/dataset/goose/dataset.py
Rellis3DDataset
apairo.dataset.rellis.Rellis3DDataset
Bases: ProfiledDataset
RELLIS-3D dataset -- off-road LiDAR with semantic labels.
Keys: lidar (float32, shape (N, 4)), labels (int64).
Optional: poses (float64, shape (3, 4)) -- one 3x4 pose matrix per frame,
loaded from a per-sequence poses.txt file (one row of 12 floats per frame).
Example::
ds = Rellis3DDataset("/data/RELLIS", keys=["lidar", "labels"])
sample = ds[0]
# sample.data["lidar"] -> np.ndarray (N, 4)
# sample.data["labels"] -> np.ndarray (N,)
ds = Rellis3DDataset("/data/RELLIS", keys=["lidar", "poses"])
# sample.data["poses"] -> np.ndarray (3, 4)
Source code in apairo/dataset/rellis/dataset.py
Asynchronous datasets
RawDataset
apairo.dataset.raw.RawDataset
Bases: RootSequenceMixin, AsyncLayoutDataset, ConfigurableDataset
Generic channels.yaml-driven dataset; single sequence or dataset root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
A sequence directory or a dataset root directory --
auto-detected. A directory with no |
required |
keys
|
list[str] | None
|
Channels to load. |
None
|
declare
|
str | Path | None
|
Path to a declaration file overlaid onto the channel metadata
(per channel, per field) -- see
:class: |
None
|
Example::
ds = RawDataset(root, keys=["lidar", "imu"]) # whole dataset
ds.run_preprocess(MyLabeler()) # persisted as a new channel
Source code in apairo/dataset/raw/dataset.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
init
classmethod
init(directory: str | Path, *, merge: bool = False, overwrite: bool = False, name: str | None = None, declare: str | Path | None = None) -> Path
Write the .apairo sidecar(s) by scanning directory. Root-aware.
A sequence directory (its sub-directories hold data files) gets a
.apairo/channels.yaml with loaders inferred per channel. A root
directory (its sub-directories are sequences) gets each sequence
initialised, then a .apairo/dataset.yaml manifest (name + sequence
order + channel union).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
Sequence or dataset-root directory (auto-detected). |
required |
merge
|
bool
|
Add newly detected channels without touching existing ones. |
False
|
overwrite
|
bool
|
Discard existing |
False
|
name
|
str | None
|
Dataset name for the root manifest (default: directory name). |
None
|
declare
|
str | Path | None
|
External declaration file the scan should respect (the
in-tree |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path of the file written -- |
Path
|
|
Source code in apairo/dataset/raw/dataset.py
TartanKittiDataset
apairo.dataset.tartan_kitti.TartanKittiDataset
Bases: RawDataset
TartanDrive v2 -- a :class:~apairo.dataset.raw.RawDataset whose channel
set is the fixed TartanDrive profile.
Loading, multi-sequence roots, synchronization and preprocessing are exactly
:class:RawDataset's; this class only pins the canonical TartanDrive
channels (profile.yaml). That means a raw sequence with no .apairo
bootstraps with the profile's loaders rather than ones merely guessed from
file extensions, and :meth:describe can flag profile channels missing on
disk.
Single sequence or root directory, auto-detected::
ds = TartanKittiDataset(seq_dir, keys=["velodyne_0", "cmd"])
ds = TartanKittiDataset(root_dir, keys=["velodyne_0"]) # all sequences
Source code in apairo/dataset/tartan_kitti/dataset.py
AsyncLayoutDataset
Abstract per-channel layout base for the asynchronous family. Internal base
class — subclass it to add a fixed-channel async dataset; end users load through
RawDataset or TartanKittiDataset.
apairo.dataset.async_layout.AsyncLayoutDataset
Bases: AbstractDataset
Abstract asynchronous layout loader (one subdirectory per channel).
This is the format primitive of the asynchronous dataset family. It is not
a concrete dataset -- the synchronous KITTI-style datasets are
:class:~apairo.core.profiled_dataset.ProfiledDataset subclasses (e.g.
:class:~apairo.dataset.semantic_kitti.SemanticKittiDataset).
It describes how channels are stored, never which channels exist: each
channel is a subdirectory with its own timestamps.txt and data files in
a format known to the loader registry (npys, npy, bin, img,
zarr). A channel may instead carry its alignment key in its filenames --
a key: {name: <regex>} / {file: <name>} spec parses it in memory at
read time (nothing written), with an optional order enumeration policy;
see docs/datasets/bring-your-own-dataset.md. The set of channels is
per-instance state, read from .apairo/channels.yaml (or an explicit
dataset_profile). Datasets
with a fixed channel set layer a profile on top (e.g.
:class:~apairo.dataset.tartan_kitti.TartanKittiDataset); datasets with
dynamic channels (e.g. apairo-extractor output) use
:class:~apairo.dataset.raw.RawDataset, which reads the channel set from
.apairo with no profile.
Usage with an explicit profile (original API)::
ds = AsyncLayoutDataset(seq_dir, keys=["lidar", "cam"], dataset_profile="my.yaml")
Usage with .apairo (after :meth:init has been called)::
AsyncLayoutDataset.init(seq_dir) # once, auto-detects channels
ds = AsyncLayoutDataset(seq_dir) # keys and loaders come from .apairo
ds = AsyncLayoutDataset(seq_dir, keys=["lidar"]) # restrict to a subset
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
Path to the dataset root / sequence directory. |
required |
keys
|
list[str] | None
|
Modality names to load. |
None
|
dataset_profile
|
str | Path | None
|
YAML profile filename or absolute Path mapping keys
to loader types. |
None
|
declare
|
str | Path | None
|
Path to a declaration file (the
|
None
|
declare_base
|
str | Path | None
|
Lower-precedence declaration overlaid before the
in-tree |
None
|
Source code in apairo/dataset/async_layout/dataset.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 | |
frame_sequence_ids
property
Sequence id per global event -- the sequence directory name (a single
async dataset is one sequence). Object array of shape (len(self),).
frame_channel_ids
property
Channel that produced each global event. Object array of shape
(len(self),), vectorized from the merged timeline.
frame_stems
property
Filename stem backing each global event: the per-frame data file's stem, or the zero-padded row for stacked (single-file) channels.
init
classmethod
init(directory: str | Path, *, raw_keys: list[str] | None = None, overwrite: bool = False, merge: bool = False, declare: str | Path | None = None) -> Path
Scan an async-layout directory and write .apairo/channels.yaml.
All detected subdirectories are registered as raw channels. Loader type is inferred from file extensions:
.bin→bin.pcd→pcd.png/.jpg/ … →img- multiple
.npyfiles →npys - single
.npyfile →npy
For ambiguous cases (e.g. a single-frame .npy that is actually
per-frame), call :func:~apairo.core.config.register_raw_channel
afterwards to override the detected loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
Dataset root / sequence directory to initialize. |
required |
raw_keys
|
list[str] | None
|
Subdirectory names to include. |
None
|
overwrite
|
bool
|
Discard the existing |
False
|
merge
|
bool
|
Add newly detected raw channels to an existing |
False
|
declare
|
str | Path | None
|
Path to an external declaration file the scan should
respect, in addition to the in-tree |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path of the written |
Raises:
| Type | Description |
|---|---|
ValueError
|
If both |
FileExistsError
|
If |
ValueError
|
If no new recognizable channels are found. |
Source code in apairo/dataset/async_layout/dataset.py
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | |
frame_info
Channel + row each interleaved event came from. See
:meth:AbstractDataset.frame_info.
Source code in apairo/dataset/async_layout/dataset.py
StreamDataset
apairo.dataset.stream.StreamDataset
Bases: AbstractDataset
In-memory asynchronous dataset built from timestamped event streams.
The bridge between live or freshly-decoded data (ROS messages, queue
items, arrays in RAM) and the apairo API: give it one (timestamps,
items) pair per channel and it behaves exactly like a file-backed
asynchronous dataset -- merged timeline, single-event samples, and above
all :meth:~apairo.core.abstract_dataset.AbstractDataset.synchronize::
ds = StreamDataset({
"image": (img_ts, img_msgs), # any indexable items
"lidar": (lidar_ts, lidar_msgs),
"odom": (odom_ts, odom_msgs),
})
ds[0] # one event, timestamp-ordered
frames = ds.synchronize(reference=clock, method="previous")
Items are stored as given -- they can be numpy arrays, ROS messages, or any Python objects; apairo never copies or converts them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
streams
|
dict[str, tuple[ndarray, Sequence]]
|
|
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
On empty streams, length mismatch, or non-ascending timestamps. |
Source code in apairo/dataset/stream.py
frame_channel_ids
property
Channel that produced each global event. Object array of shape
(len(self),), vectorized from the merged timeline.
frame_info
Channel + per-channel row each interleaved event came from -- async, so it mirrors AsyncLayoutDataset rather than the synchronous default.
Source code in apairo/dataset/stream.py
SynchronizedView
apairo.core.synchronized_view.SynchronizedView
Bases: AbstractDataset
A synchronous view over an asynchronous dataset.
Created by :meth:~apairo.core.abstract_dataset.AbstractDataset.synchronize.
Index i returns a complete sample built around the i-th tick of the
reference clock: every channel contributes either an existing event
matched by timestamp, or a value synthesized at the tick by an
:class:~apairo.core.interpolator.Interpolator. The matching is a pure
index computation (one np.searchsorted per channel at construction
time) -- no data is read until access.
Because the view is synchronous (timestamps is None), the full
chaining API applies: .filter(), .select(), .cache(),
.join(), and map-style PyTorch DataLoader with shuffling.
.. note:: The view reads channel data directly from the parent's loaders -- transforms registered on the parent are not applied (they were written for single-event samples). Register transforms on the view::
ds_sync = ds.synchronize().transform("velodyne_0", RangeFilter(50))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
AbstractDataset
|
Asynchronous dataset exposing per-channel |
required |
reference
|
str | ndarray | None
|
The clock to resample onto. Three forms:
|
None
|
method
|
ChannelStrategy | dict[str, ChannelStrategy]
|
Strategy applied to every channel, or a dict mapping channel
names to per-channel strategies (unlisted channels default to
|
'previous'
|
tolerance
|
float | None
|
Maximum |
None
|
Example::
from apairo_transform.interp import Se3Interp
ds = TartanKittiDataset(seq, keys=["velodyne_0", "gicp_poses"])
ds_sync = ds.synchronize(
reference="velodyne_0",
method={"gicp_poses": Se3Interp()}, # velodyne_0 -> "previous"
tolerance=0.05,
)
s = ds_sync[0]
s.data["gicp_poses"] # pose interpolated at s.timestamp
Source code in apairo/core/synchronized_view.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |
root_dir
property
Delegates to the parent's root_dir (or None if it has
none), so .calibration still resolves on a synchronized view --
without this, every synchronized view read an empty Calibration
regardless of what its parent exposed.
reference
property
Channel providing the clock, or None for an external clock.
reference_timestamps
property
Timestamp of each frame in the view (reference clock).
frame_indices
property
Per-channel event indices backing each frame.
Shape (n,) for matched channels (the event used), (n, 2) for
interpolated channels (the bracketing pair).
frame_sequence_ids
cached
property
Sequence id per synchronised frame, shape (n,).
A synchronised frame mixes events from several channels, so it only
carries a sequence id when the whole parent belongs to one sequence;
over a multi-sequence parent this raises AttributeError, keeping
the availability probe of the base class.
frame_channel_ids
property
Unavailable: a synchronised frame composites every channel (see
:meth:frame_info), so there is no single origin channel -- unlike
:attr:frame_sequence_ids, this raises unconditionally, even over a
single-sequence parent. Use :attr:frame_indices for real per-channel
provenance.
time_offsets
Signed t_event - t_ref per frame for key, in seconds.
Interpolated channels return zeros: their values are synthesized at the reference instant.
Source code in apairo/core/synchronized_view.py
frame_info
Provenance of synchronised frame idx.
A synchronised frame is composite: each channel is backed by its own
source event (see :attr:frame_indices), so there is no single origin
channel -- channel is None and row is the view index, not
an on-disk row (unlike a profiled dataset, where row addresses a file
on disk). sequence is filled when the parent belongs to a single
sequence (see :attr:frame_sequence_ids), None otherwise.
For real per-frame provenance use :attr:frame_indices;
frame_indices[self.reference][idx] is the reference-clock event this
tick was resampled onto.
Source code in apairo/core/synchronized_view.py
Interpolator
apairo.core.interpolator.Interpolator
Bases: ABC
Synthesize a channel value at the reference instant from its two bracketing events.
This is the value-level counterpart of the index-level matching
strategies ("previous", "next", "nearest"): instead of
picking an existing
event, an interpolator builds a new value at t_ref. Use it for
continuous signals -- poses, IMU, commands -- never for data that cannot
be blended (point clouds, images).
Contract, as orchestrated by
:class:~apairo.core.synchronized_view.SynchronizedView:
- a channel whose strategy is an
Interpolatorreceives, for each reference tickt, its two bracketing events(t0, v0)and(t1, v1)witht0 <= t <= t1andt0 < t1; - ticks not bracketed by two events (before the first event or after the last) are dropped from the view;
- exact matches (
t == t0) bypass the interpolator -- the stored value is returned directly, so implementations never seet0 == t1; - with
tolerance, both neighbours must lie within tolerance oft(max(t - t0, t1 - t) <= tolerance).
Concrete implementations (LinearInterp, Se3Interp, ...) live in
apairo_transform.interp.
Example::
class LinearInterp(Interpolator):
def __call__(self, t, t0, v0, t1, v1):
a = (t - t0) / (t1 - t0)
return (1.0 - a) * v0 + a * v1
Source code in apairo/core/interpolator.py
__call__
abstractmethod
Dataset composition
ConcatDataset
apairo.dataset.concat.ConcatDataset
Bases: AbstractDataset
Concatenates multiple dataset instances into one.
Takes the intersection of keys across all datasets so every index returns the same set of modalities regardless of which underlying dataset is hit. Indexing is O(log n) via binary search over cumulative lengths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasets
|
list[AbstractDataset]
|
Non-empty list of dataset instances to concatenate. |
required |
Example::
sequences = [
SemanticKittiDataset(f"/data/kitti/seq_{i:02d}", keys=["lidar", "labels"])
for i in range(11)
]
combined = ConcatDataset(sequences)
sample = combined[0]
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in apairo/dataset/concat.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
timestamps
cached
property
The concatenated clock. Gated on the structural is_synchronous
protocol -- every view implements it, whereas the view wrappers do not
all define a bare .timestamps attribute. A synchronous child exposes a
shared per-frame ndarray clock (or None); an asynchronous child a
per-channel dict.
frame_sequence_ids
cached
property
Sequence id per global frame, concatenated from the children.
Ids are forwarded verbatim -- two children exposing the same id stay
indistinguishable. Raises AttributeError when any child exposes
none, so the availability probe keeps working.
frame_stems
cached
property
Filename stem per global frame, concatenated from the children.
frame_channel_ids
cached
property
Channel that produced each global frame, concatenated from the children.
frame_info
Provenance of frame idx, delegated to the dataset that owns it.
split_sequences
apairo.dataset.split_sequences
split_sequences(datasets: list, ratios: tuple[float, float, float] = (0.8, 0.1, 0.1)) -> tuple[list, list, list]
Split datasets into train/val/test at the sequence level.
Splitting at sequence level avoids temporal leakage between splits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasets
|
list
|
Ordered list (one entry per recording session). |
required |
ratios
|
tuple[float, float, float]
|
(train, val, test) fractions, must sum to 1.0. |
(0.8, 0.1, 0.1)
|
Source code in apairo/dataset/__init__.py
Extensibility
ConfigurableDataset
apairo.core.configurable_dataset.ConfigurableDataset
Mixin for datasets that support preprocessed-channel extensibility via .apairo.
Any dataset class that wants to be extensible at runtime (i.e. allow users to register new preprocessed channels without touching source code) should inherit from this mixin alongside its normal base class.
Concrete subclasses must implement :meth:_bootstrap_config, which describes
how to auto-discover the dataset's raw channels when .apairo does not yet
exist.
Usage pattern for preprocessing scripts::
MyDataset.register_channel(
seq_dir, "my_channel", "npys",
timestamps_from="lidar",
sources=["lidar"],
)
Usage in dataset __init__::
config = self._load_or_create_config(sequence_dir)
Source code in apairo/core/configurable_dataset.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
run_preprocess
class-attribute
instance-attribute
Run a preprocessor and persist the output channel.
Can be called on the class or on an existing instance:
Class form -- root_dir required::
Goose3DDataset.run_preprocess(preprocessor, "/data/GOOSE_3D", split="train")
Instance form -- root_dir inferred from the dataset::
ds = Goose3DDataset("/data/GOOSE_3D", keys=["lidar"], split="train")
ds.run_preprocess(preprocessor)
Extra keyword arguments are forwarded to the dataset constructor (class form)
or ignored (instance form, since the instance is already configured).
overwrite=True recomputes even if the output already exists.
To preview a :class:~apairo.core.preprocessor.FramePreprocessor without
writing anything, run the same instance lazily first:
ds.transform(preprocessor).
register_channel
classmethod
register_channel(sequence_dir: str | Path, key: str, loader: str, *, timestamps_from: str | None = None, sources: list[str] | None = None, recipe: str | None = None) -> None
Register a preprocessed channel in sequence_dir/.apairo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence_dir
|
str | Path
|
Dataset sequence directory. |
required |
key
|
str
|
Channel name -- must match its subdirectory name. |
required |
loader
|
str
|
Data format: |
required |
timestamps_from
|
str | None
|
Channel whose timestamps to share when this channel
has no |
None
|
sources
|
list[str] | None
|
Provenance -- channels this channel was derived from. |
None
|
recipe
|
str | None
|
Content hash of the producing preprocessor's declared config
(set by |
None
|
Source code in apairo/core/configurable_dataset.py
remove_channel
classmethod
Remove a channel from sequence_dir/.apairo (inverse of
:meth:register_channel).
By default only the declaration is dropped, which is reversible; pass
data=True to also delete the channel's directory on disk. Returns the
removed metadata entry. For an interactive guard on raw channels and
data deletion, prefer the CLI (apairo channel remove).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence_dir
|
str | Path
|
Dataset sequence directory. |
required |
key
|
str
|
Channel name to remove (its on-disk directory name). |
required |
data
|
bool
|
Also delete the channel's directory from disk (destructive). |
False
|
Source code in apairo/core/configurable_dataset.py
describe
classmethod
Describe what is available in a sequence directory.
Reads .apairo (creating it if absent) and cross-references it with
the class's :attr:available_keys to produce a three-way breakdown:
- raw / present -- raw channels on disk and registered
- raw / missing -- raw channels known from the profile but not on disk
- preprocess -- channels produced by a preprocessing pipeline
Returns the breakdown as a dict and prints a human-readable summary.
Example::
MyDataset.describe("/data/my_dataset/sequence_01")
Source code in apairo/core/configurable_dataset.py
register_raw_channel
classmethod
register_raw_channel(sequence_dir: str | Path, key: str, loader: str, *, alias: str | None = None, directory: str | None = None, suffix: str | None = None) -> None
Declare a raw channel in sequence_dir/.apairo.
Use this to manually add or override a raw channel declaration, for
example after :meth:init detected the wrong loader type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence_dir
|
str | Path
|
Dataset sequence directory. |
required |
key
|
str
|
Channel name -- must match its subdirectory name. |
required |
loader
|
str
|
Data format: |
required |
alias
|
str | None
|
Public name to expose the channel under at load time (the
directory keeps its real name). See
:func: |
None
|
directory
|
str | None
|
On-disk subdirectory this channel's files live in, when different from key (a suffixed sub-channel sharing another channel's directory). Defaults to key. |
None
|
suffix
|
str | None
|
Frame-file suffix to load from directory (e.g.
|
None
|
Source code in apairo/core/configurable_dataset.py
verify
classmethod
Verify that .apairo is coherent with what is on disk.
Prints any issues found and returns True when the config is clean.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence_dir
|
str | Path
|
Dataset sequence directory containing |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Example::
ok = MyDataset.verify("/data/my_dataset/seq_01")
Source code in apairo/core/configurable_dataset.py
RootSequenceMixin
Shared single-sequence vs. dataset-root handling for the asynchronous family
(flat indexing, per-sequence access, per-sequence synchronize + concat).
Reused by RawDataset and TartanKittiDataset.
apairo.core.root_sequence.RootSequenceMixin
Bases: AbstractDataset
Flat-indexed root over several same-typed sequence datasets.
Source code in apairo/core/root_sequence.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
calibration
property
Static extrinsics from .apairo/calibration.yaml (e.g. written from
/tf_static). On a root, sequences' tables are merged -- each sequence
carries its own, so the calibration follows the data, not the root.
available
property
Channels available -- intersection across sequences for a root dataset.
sequence_ids
property
Sequence directory names, in load order (root datasets only).
frame_sequence_ids
property
Sequence id per global frame index (object array). On a root, the sub-sequence each frame belongs to; on a single sequence, delegated.
frame_stems
property
Filename stem per global frame index, concatenated over sequences.
frame_channel_ids
property
Channel that produced each global frame index, concatenated over sequences.
sequence
Return a :class:~apairo.core.sequence_view.SequenceView for seq_id.
Source code in apairo/core/root_sequence.py
synchronize
Resample onto a reference clock -- see :meth:AbstractDataset.synchronize.
On a root dataset each sequence is synchronized independently (clocks are not comparable across recordings) and the results concatenated, so an external clock array is only valid on a single sequence.
Source code in apairo/core/root_sequence.py
frame_info
Channel + row each event came from, plus the sub-sequence it belongs
to (root datasets). See :meth:AbstractDataset.frame_info.
Source code in apairo/core/root_sequence.py
register_channel
apairo.core.config.register_channel
register_channel(root_dir: str | Path, key: str, loader: str, *, timestamps_from: str | None = None, sources: list[str] | None = None, frame: str | None = None, recipe: str | None = None) -> None
Register a preprocessed channel in root_dir/.apairo/channels.yaml.
This is the low-level standalone function. Most users will prefer the
classmethod :meth:ConfigurableDataset.register_channel so that the call
site names the dataset type explicitly.
Existing channels (raw or preprocessed) are preserved -- only key is
updated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root_dir
|
str | Path
|
Dataset root directory. |
required |
key
|
str
|
Channel name -- must match its subdirectory name. |
required |
loader
|
str
|
Data format: |
required |
timestamps_from
|
str | None
|
Source channel whose timestamps this channel shares
(provenance only -- the channel always has its own |
None
|
sources
|
list[str] | None
|
Provenance -- raw channels this channel was derived from. |
None
|
frame
|
str | None
|
Coordinate frame the channel's data is expressed in (descriptive metadata only; apairo does not apply transforms). |
None
|
recipe
|
str | None
|
Content hash of the producing preprocessor's declared config, so
a later |
None
|
Source code in apairo/core/config.py
WRITERS
Format writers used by the preprocessing runner.
Keyed by loader name ("npy", "npys", "bin", "zarr", "img").
from apairo import WRITERS
writer = WRITERS["npy"]()
writer.write(my_array, Path("/data/output/000000.npy"))
apairo.writer.WRITERS
module-attribute
WRITERS: dict[str, type] = {'npy': NPYWriter, 'npys': NPYWriter, 'bin': BINWriter, 'zarr': ZarrWriter, 'img': TarImageWriter}
DERIVED_LOADERS
File-level loaders for derived/preprocessed keys.
Keyed by loader name ("npy", "bin", "img").
Each entry is a Callable[[Path], np.ndarray].
apairo.loader.DERIVED_LOADERS
module-attribute
DERIVED_LOADERS: dict[str, Callable[[Path], ndarray]] = {'npy': lambda path: np.load(path), 'bin': lambda path: np.fromfile(path, dtype=np.float32), 'img': _load_img, 'pcd': lambda path: read_pcd(str(path))}
Preprocessing
FramePreprocessor
apairo.core.preprocessor.FramePreprocessor
Bases: Preprocessor
Preprocessor that operates frame-by-frame.
The runner calls the instance once per input frame. Use this for per-scan operations (label inference, feature extraction, …).
Output is stored as one file per frame (000000.npy, 000001.npy,
…) when output_loader is "npys" or "bin".
Because a frame preprocessor is just a Sample -> value callable, it
can also run lazily -- ds.transform(preprocessor) publishes its
result under output_key at access time, nothing is written. Preview
a preprocess this way before materializing it with run_preprocess.
Example::
class TravLabel(FramePreprocessor):
output_key = "trav_label"
output_loader = "npys"
input_keys = ["velodyne_0"]
timestamps_from = "velodyne_0" # no own timestamps.txt
def __call__(self, sample: Sample) -> np.ndarray:
pts = sample.data["velodyne_0"]
return my_model(pts)
Source code in apairo/core/preprocessor.py
__call__
abstractmethod
Process one frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
Sample
|
A :class: |
required |
Returns:
| Type | Description |
|---|---|
Any
|
A |
Source code in apairo/core/preprocessor.py
SequencePreprocessor
apairo.core.preprocessor.SequencePreprocessor
Bases: Preprocessor
Preprocessor that operates on the full sequence at once.
The runner calls the instance with an iterator over all input frames.
Use this for algorithms that need global context (ICP, trajectory
smoothing, …). Global context is also why a sequence preprocessor
cannot run lazily: it must be materialized via run_preprocess.
Output is stored as a single {output_key}.npy file when
output_loader is "npy".
Example::
class GICPPoses(SequencePreprocessor):
output_key = "gicp_poses"
output_loader = "npy"
input_keys = ["velodyne_0"]
sources = ["velodyne_0"] # has its own timestamps.txt
def __call__(self, frames: Iterator[Sample]) -> np.ndarray:
poses = []
for sample in frames:
pts = sample.data["velodyne_0"]
poses.append(register(pts))
return np.stack(poses) # (N, 4, 4)
Source code in apairo/core/preprocessor.py
__call__
abstractmethod
Process all frames.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frames
|
Iterator[Sample]
|
Iterator of :class: |
required |
Returns:
| Type | Description |
|---|---|
Any
|
A |
Source code in apairo/core/preprocessor.py
Data structures
Sample
apairo.core.sample.Sample
dataclass
A single dataset sample -- one timeline event or one complete frame.
timestamp follows the frame's clock, not merely whether the data is
synchronous:
- Asynchronous event --
datahas one key;timestampis that event's. - Synchronous clocked frame (a
synchronize()result) --datahas all requested keys;timestampis the reference-clock tick the frame was resampled onto. - Synchronous clockless frame (a profiled dataset) --
datahas all keys;timestampisNone.
Source code in apairo/core/sample.py
FrameRef
Returned by AbstractDataset.frame_info(idx) -- where a global frame index comes
from (sequence, channel, row).
apairo.core.abstract_dataset.FrameRef
Bases: NamedTuple
Where a global frame index comes from -- for layout-aware tooling.
Returned by :meth:AbstractDataset.frame_info. Lets a visualizer or splitter
map a flat index back to its origin without reaching into private timeline
state.
Attributes:
| Name | Type | Description |
|---|---|---|
sequence |
str | None
|
Sub-sequence the frame belongs to ( |
channel |
str | None
|
Channel that produced the event -- asynchronous datasets
interleave channels, so one event is one channel. |
row |
int
|
Frame index within that channel/sequence. |