# py123d_detection
Camera-based 3D object detection on [123D](https://kesai.eu/py123d/) data.
The package is two halves that share a data model, a taxonomy and an evaluation metric. Pick the
one that matches the stack you are already in.
## Export to mmdetection3d — `py123d_detection.mmcv`
Writes the `info` pickle mmdet3d reads, so existing PETR, StreamPETR, BEVDet and CoIn3D configs
train on any 123D dataset, or several at once, unchanged. The exporter itself needs no mmcv; only
the environment that trains does.
Start at [Quick start](quickstart.md).
## Train without mmcv — `py123d_detection.torch`
Reads 123D logs straight into PyTorch. PETR and BEVFormer on Lightning and Hydra, no mmcv
anywhere. Ported from the thesis these numbers come from, and held to it by frozen fixtures.
Start at [First run](guides/first-run.md).
## Why this exists
123D already normalizes a dozen driving datasets into one schema. mmdetection3d reads exactly one
format, the nuScenes `info` pickle, and every camera-based detector built on it (PETR, StreamPETR,
BEVDet, CoIn3D) reads that and nothing else. CoIn3D's cross-dataset training, for instance, works
by converting Waymo and Lyft into the pickle and concatenating the results.
So one converter from 123D into that format makes every 123D dataset trainable with off-the-shelf
configs, individually or mixed.
## How it fits together
There are two routes from a raw dataset to the pickle a detector trains on. The first needs a
hand-written converter for every dataset. The second needs none, because the per-dataset work
already happened when 123D was built.
```mermaid
flowchart TD
RAW["Raw dataset
nuScenes, Argoverse 2, Waymo, ..."]
RAW --> NATIVE["mmdetection3d converter
tools/create_data.py
one per dataset, hand-written"]
RAW --> CONV["123D conversion
py123d-conversion"]
NATIVE --> PKLA["info pickle"]
CONV --> LOGS["123D logs
Arrow tables, one schema
for every dataset"]
LOGS --> EXPORT["py123d_detection exporter
py123det-export-mmcv
one converter, every dataset"]
EXPORT --> PKLB["info pickle"]
PKLA --> CFG["mmdet3d config
ann_file=..."]
PKLB --> CFG
CFG --> MODEL["PETR / StreamPETR /
BEVDet / CoIn3D"]
style PKLA fill:#eef4fb,stroke:#2a78d6
style PKLB fill:#eef4fb,stroke:#2a78d6
style LOGS fill:#fdf1ea,stroke:#eb6834
style EXPORT fill:#fdf1ea,stroke:#eb6834
```
The two pickles are interchangeable. That claim is measured, not asserted: see
[Does the output match the native converter?](validation.md#does-the-output-match-the-native-converter).
Inside the 123D route, these are the pieces you actually name in your own code or on the command
line. Everything else is internal.
```mermaid
flowchart TD
LOGS["123D logs"] --> SRC
subgraph EXPORTENV ["conversion environment: py123d + numpy"]
SRC["Source
py123d_detection
which logs, which splits,
what frame rate"]
TAX["Taxonomy
py123d_detection
123D labels to class names
presets: nuscenes_detection_10cls,
general_3cls, coin3d_3cls, ..."]
CONF["ExportConfig
py123d_detection.mmcv.export
cameras, reference frame, box layout,
sweeps, velocity, tokens, paths"]
RUN["export_to_mmdet3d()
py123d_detection.mmcv.export"]
REP["ExportReport
frame / box / class counts,
skips, warnings"]
SRC --> RUN
TAX --> CONF
CONF --> RUN
RUN --> REP
end
RUN --> PKL["info pickle
infos + metadata"]
subgraph TRAINENV ["training environment: mmcv / mmdet3d"]
STOCK["NuScenesDataset
stock mmdet3d,
nothing to install"]
PLUG["Py123DNuScenesDataset
py123d_detection.mmcv.plugin
portable arrays, taxonomy classes,
evaluation without a nuScenes DB"]
end
PKL --> STOCK
PKL --> PLUG
style PKL fill:#eef4fb,stroke:#2a78d6
style LOGS fill:#fdf1ea,stroke:#eb6834
```
The CLI is the same three objects behind a flag parser. `py123det-export-mmcv export` builds a
`Source` and an `ExportConfig` from its arguments and calls `export_to_mmdet3d`.
```{toctree}
:hidden:
:caption: Start here
installation
```
```{toctree}
:hidden:
:caption: Export to mmdetection3d
quickstart
guides/choosing-what-to-export
guides/cross-dataset-training
guides/extrinsics
guides/sensor-payloads
guides/tokens-and-evaluation
guides/python-version-boundary
other-datasets
examples
```
```{toctree}
:hidden:
:caption: Train without mmcv
guides/first-run
guides/training
guides/visualisation
```
```{toctree}
:hidden:
:caption: Reference
validation
cli
api/index
```
```{toctree}
:hidden:
:caption: Development
contributing
development
```