py123d_detection.core.taxonomy

Mapping 123D box labels onto the class_names tuple of an mmdet3d config.

A Taxonomy turns a 123D label into one of its class names, or drops the box. Lookups go from most to least specific:

  1. native_map by qualified enum member ("AV2SensorBoxDetectionLabel.BICYCLIST"), for when the same member name exists in several datasets and only one should be overridden;

  2. native_map by bare member name ("VEHICLE_CAR");

  3. default_map by DefaultBoxDetectionLabel member ("VEHICLE"). Every 123D dataset implements to_default(), so a default-level taxonomy works for all of them, which is what cross-dataset merges rely on.

Labels that resolve to VOID, or to nothing, are dropped.

Some datasets box a rider separately from the vehicle they are on: Argoverse 2 and KITTI-360 annotate BICYCLIST next to BICYCLE, while nuScenes and Waymo annotate one object. MergeRule reconciles them by pairing the two boxes and emitting their hull, so the same scene yields the same objects whichever dataset it came from. A rule’s sources are intermediate class names, reachable from a label but absent from Taxonomy.class_names, which is what keeps a rule scoped to the datasets that need it. Anything still intermediate after merging is dropped.

Module Attributes

VOID

Target class name that drops a label.

NUSCENES_DETECTION

The standard nuScenes 10-class benchmark, in mmdet3d's class order.

GENERAL_3CLS

Cross-dataset vehicle / pedestrian / cyclist over the default labels.

COIN3D_3CLS

CoIn3D's unified classes, spelled with nuScenes names on purpose: the devkit's DetectionBox only accepts the ten nuScenes detection names, and reusing three of them lets any dataset be scored with the unmodified metric code.

MIXED_8CLS

Eight classes: the nuScenes ten with construction_vehicle folded into truck and barrier dropped.

MIXED2_3CLS

Three classes across datasets: everything that drives is vehicle, a motorcycle included, and only a bicycle stays separate.

MIXED3_1CLS

One class: everything that drives, a motorcycle and its rider included.

VEHICLE_1CLS

A single vehicle class over the default labels (VEHICLE and TRAIN).

DEFAULT_123D

Identity over DefaultBoxDetectionLabel, minus EGO.

TAXONOMIES

The values accepted by --taxonomy.

Functions

class_permutation(old_class_names, ...)

Indices that reorder rows laid out as old_class_names into new_class_names.

get_taxonomy(name)

remap_head_classes(state_dict, ...[, marker])

Reorder a trained classification head from one class order to another.

Classes

MergeRule(target, sources[, ...])

Combine a rider and its vehicle into one box.

Taxonomy(name, class_names[, native_map, ...])

An ordered class list plus the rules mapping 123D labels onto it.

py123d_detection.core.taxonomy.VOID = 'void'

Target class name that drops a label.

class py123d_detection.core.taxonomy.MergeRule(target, sources, discard_unmerged_base=False)[source]

Bases: object

Combine a rider and its vehicle into one box.

Secondaries are paired to primaries by bird’s-eye-view IoU, greedily and highest first, and a pair becomes the tight box around both sets of corners, keeping the primary’s orientation and velocity. A secondary that pairs with nothing is dropped, since a rider with no vehicle is not an object this taxonomy has a class for.

target: str

Class name the merged box gets. Must be in Taxonomy.class_names.

sources: Tuple[str, ...]

Class names to combine. The first is the primary and keeps its yaw and velocity.

discard_unmerged_base: bool = False

Drop a primary that paired with nothing, instead of keeping it as target.

Set it where a lone primary is not the object you mean: an Argoverse BICYCLE with no BICYCLIST is a parked bicycle, not a cyclist.

property primary: str
property secondaries: Tuple[str, ...]
class py123d_detection.core.taxonomy.Taxonomy(name, class_names, native_map=<factory>, default_map=<factory>, merge_rules=())[source]

Bases: object

An ordered class list plus the rules mapping 123D labels onto it.

name: str

Identifier stored in the exported metadata, e.g. "nuscenes_detection_10cls".

class_names: Tuple[str, ...]

Ordered class names. The index of a name is its label id in the mmdet3d config.

native_map: Mapping[str, str]

Dataset-native (optionally qualified) enum member name -> class name or VOID.

default_map: Mapping[str, str]

DefaultBoxDetectionLabel member name -> class name or VOID.

merge_rules: Tuple[MergeRule, ...] = ()

Rules combining a rider with its vehicle. See MergeRule.

property intermediate_names: FrozenSet[str]

Merge-source names that are not classes in their own right.

property mapped_names: Tuple[str, ...]

Every class name some label maps to, VOID excluded.

is_final(class_name)[source]

Whether class_name survives on its own, i.e. is not merge-only.

Return type:

bool

resolve(label)[source]

Class name for a 123D label, or None if the box should be dropped.

Return type:

Optional[str]

label_id(class_name)[source]
Return type:

int

property class_ids: Dict[str, int]
rule_for(class_name)[source]

The merge rule class_name takes part in, if any.

Return type:

Optional[MergeRule]

py123d_detection.core.taxonomy.NUSCENES_DETECTION = Taxonomy(name='nuscenes_detection_10cls')

The standard nuScenes 10-class benchmark, in mmdet3d’s class order. Native-level only, so any other dataset exported with it drops every box.

py123d_detection.core.taxonomy.GENERAL_3CLS = Taxonomy(name='general_3cls')

Cross-dataset vehicle / pedestrian / cyclist over the default labels.

py123d_detection.core.taxonomy.COIN3D_3CLS = Taxonomy(name='coin3d_3cls')

CoIn3D’s unified classes, spelled with nuScenes names on purpose: the devkit’s DetectionBox only accepts the ten nuScenes detection names, and reusing three of them lets any dataset be scored with the unmodified metric code. CoIn3D’s mapping (data_preprocess/README.md): nuScenes car/truck/trailer/bus/construction_vehicle -> car, pedestrian -> pedestrian, bicycle/motorcycle -> motorcycle; Lyft car/truck/bus/emergency_vehicle/other_vehicle -> car; Waymo VEHICLE/PEDESTRIAN/CYCLIST.

py123d_detection.core.taxonomy.MIXED_8CLS = Taxonomy(name='mixed_8cls')

Eight classes: the nuScenes ten with construction_vehicle folded into truck and barrier dropped. The thesis called this “mixed”.

py123d_detection.core.taxonomy.MIXED2_3CLS = Taxonomy(name='mixed2_3cls')

Three classes across datasets: everything that drives is vehicle, a motorcycle included, and only a bicycle stays separate. The thesis called this “mixed2”.

py123d_detection.core.taxonomy.MIXED3_1CLS = Taxonomy(name='mixed3_1cls')

One class: everything that drives, a motorcycle and its rider included. The thesis called this “mixed3” and used it to compare camera rigs, where a second class only adds a way for the comparison to move for a reason that is not the rig.

It is MIXED2_3CLS with pedestrian and bicycle dropped rather than VEHICLE_1CLS with a shorter class list: a motorcycle counts as a vehicle here, an Argoverse rider is merged onto the machine they ride, and a train does not count at all.

py123d_detection.core.taxonomy.VEHICLE_1CLS = Taxonomy(name='vehicle_1cls')

A single vehicle class over the default labels (VEHICLE and TRAIN). Simpler than MIXED3_1CLS: no dataset-native overrides, so a two-wheeler never counts.

py123d_detection.core.taxonomy.DEFAULT_123D = Taxonomy(name='default_123d')

Identity over DefaultBoxDetectionLabel, minus EGO.

py123d_detection.core.taxonomy.TAXONOMIES: Dict[str, Taxonomy] = {'coin3d_3cls': Taxonomy(name='coin3d_3cls'), 'default_123d': Taxonomy(name='default_123d'), 'general_3cls': Taxonomy(name='general_3cls'), 'mixed2_3cls': Taxonomy(name='mixed2_3cls'), 'mixed3_1cls': Taxonomy(name='mixed3_1cls'), 'mixed_8cls': Taxonomy(name='mixed_8cls'), 'nuscenes_detection_10cls': Taxonomy(name='nuscenes_detection_10cls'), 'vehicle_1cls': Taxonomy(name='vehicle_1cls')}

The values accepted by –taxonomy.

py123d_detection.core.taxonomy.get_taxonomy(name)[source]
Return type:

Taxonomy

py123d_detection.core.taxonomy.class_permutation(old_class_names, new_class_names)[source]

Indices that reorder rows laid out as old_class_names into new_class_names.

result[i] is where the class now at position i used to sit, so rows[permutation] is the reordered array.

Raises:

ValueError – if the two lists are not the same set of names. A permutation is only meaningful when nothing is added or removed.

Return type:

List[int]

py123d_detection.core.taxonomy.remap_head_classes(state_dict, old_class_names, new_class_names, marker='cls_branches')[source]

Reorder a trained classification head from one class order to another.

Class ids are positions, so the same ten nuScenes names in a different order mean a checkpoint predicts the right things under the wrong labels. This permutes the rows of the head’s final weight and bias, which is the whole of what has to change.

Works on any mapping of row-indexable arrays, so a torch state dict and a dict of numpy arrays both go through and core stays free of a torch dependency.

Parameters:

marker (str) – Only parameters whose name contains this take part. Matching on shape alone would catch anything else that happens to have one row per class.

Return type:

Dict[str, Any]

Returns:

A new dict; the input is not modified.