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:
native_mapby qualified enum member ("AV2SensorBoxDetectionLabel.BICYCLIST"), for when the same member name exists in several datasets and only one should be overridden;native_mapby bare member name ("VEHICLE_CAR");default_mapbyDefaultBoxDetectionLabelmember ("VEHICLE"). Every 123D dataset implementsto_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
Target class name that drops a label. |
|
The standard nuScenes 10-class benchmark, in mmdet3d's class order. |
|
Cross-dataset vehicle / pedestrian / cyclist over the default labels. |
|
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. |
|
Eight classes: the nuScenes ten with |
|
Three classes across datasets: everything that drives is |
|
One class: everything that drives, a motorcycle and its rider included. |
|
A single |
|
Identity over DefaultBoxDetectionLabel, minus EGO. |
|
The values accepted by --taxonomy. |
Functions
|
Indices that reorder rows laid out as |
|
|
|
Reorder a trained classification head from one class order to another. |
Classes
|
Combine a rider and its vehicle into one box. |
|
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:
objectCombine 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.
- class py123d_detection.core.taxonomy.Taxonomy(name, class_names, native_map=<factory>, default_map=<factory>, merge_rules=())[source]¶
Bases:
objectAn ordered class list plus the rules mapping 123D labels onto it.
- 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.
- property intermediate_names: FrozenSet[str]¶
Merge-source names that are not classes in their own right.
- is_final(class_name)[source]¶
Whether
class_namesurvives on its own, i.e. is not merge-only.- Return type:
- 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_vehiclefolded intotruckandbarrierdropped. 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_3CLSwith pedestrian and bicycle dropped rather thanVEHICLE_1CLSwith 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
vehicleclass over the default labels (VEHICLEandTRAIN). Simpler thanMIXED3_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.class_permutation(old_class_names, new_class_names)[source]¶
Indices that reorder rows laid out as
old_class_namesintonew_class_names.result[i]is where the class now at positioniused to sit, sorows[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:
- 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
torchstate dict and a dict of numpy arrays both go through andcorestays free of a torch dependency.