py123d_detection.core.evaluation¶
nuScenes-style detection metrics, for either branch and any set of class names.
The nuScenes devkit computes the metric this field reports, so this module runs the devkit’s own
accumulate / calc_ap / calc_tp rather than reimplementing them. What it does not use is
DetectionBox, whose constructor accepts only the ten nuScenes detection names. That single
assertion is the reason a cross-dataset taxonomy such as vehicle / pedestrian / cyclist cannot
be scored by the devkit at all, and the reason the thesis grew an 882-line reimplementation beside
it. EvalBox carries the same fields without the whitelist, so one engine serves both
branches and every taxonomy.
Ground truth and predictions arrive as EvalBox in the global frame. Each branch has
its own adapter: py123d_detection.mmcv.plugin.evaluation builds them from an exported info
pickle, the torch branch from 123D scenes.
Differences from the official protocol, all deliberate:
the ego position comes from the frame’s
ego2global_translationrather than aLIDAR_TOPego-pose record, because that is the quantity 123D actually stores;there is no bike-rack filter, since there is no
static_object.bicycle_rackto look up;123D carries no object attributes, so
attr_errisnanper box and the devkit scores it as a flat 1.0.TP_METRIC_SETSlets you drop it instead; seeevaluate().
Module Attributes
Which true-positive errors enter NDS. |
|
Errors that are meaningless for a class and are excluded from its average, as the devkit does. |
Functions
|
Fill in each box's offset from its frame's ego position, in place. |
|
A devkit |
|
Score predictions against ground truth, following |
|
The devkit's |
|
The metrics table as the devkit's |
|
Read a nuScenes-format result JSON into |
|
Wrap per-frame boxes in the devkit's |
Classes
|
One box for the metric, in the global frame. |
|
Everything the metric needs about one evaluation run. |
- py123d_detection.core.evaluation.TP_METRIC_SETS: Dict[str, Tuple[str, ...]] = {'no_attributes': ('trans_err', 'scale_err', 'orient_err', 'vel_err'), 'nuscenes': ('trans_err', 'scale_err', 'orient_err', 'vel_err', 'attr_err')}¶
Which true-positive errors enter NDS.
nuscenesis the official five.no_attributesdropsattr_err, which is what you want whenever the data carries no attributes: the devkit scores a missing attribute as the worst possible value, so keeping it subtracts a flat 0.1 from NDS that says nothing about the model. NDS is then(k * mAP + sum of k scores) / 2keither way, so the two are not comparable and the choice is recorded in the summary.
- py123d_detection.core.evaluation.UNDEFINED_TP_ERRORS: Dict[str, Tuple[str, ...]] = {'barrier': ('attr_err', 'vel_err'), 'traffic_cone': ('attr_err', 'vel_err', 'orient_err')}¶
Errors that are meaningless for a class and are excluded from its average, as the devkit does.
- class py123d_detection.core.evaluation.EvalBox(sample_token, translation, size, rotation, detection_name, velocity=(0.0, 0.0), ego_translation=(0.0, 0.0, 0.0), num_pts=-1, detection_score=-1.0, attribute_name='')[source]¶
Bases:
objectOne box for the metric, in the global frame.
Field-compatible with the devkit’s
DetectionBox, since the metric code reads these names, but without its assertion thatdetection_nameis one of the ten nuScenes classes.
- class py123d_detection.core.evaluation.EvaluationInput(ground_truth=<factory>, predictions=<factory>, ego_translations=<factory>)[source]¶
Bases:
objectEverything the metric needs about one evaluation run.
- py123d_detection.core.evaluation.build_detection_config(class_names, class_range=None, base='detection_cvpr_2019')[source]¶
A devkit
DetectionConfigrestricted toclass_names.DetectionConfig.__init__insists on the ten nuScenes classes, so the named base config is created first and its plain attributes are narrowed afterwards.- Parameters:
class_range (
Optional[Mapping[str,float]]) – Radius in metres per class, on top of the base config’s radii.- Raises:
ValueError – if a class has no radius. Guessing one silently decides how much of the scene counts, so it has to be stated.
- py123d_detection.core.evaluation.to_eval_boxes(boxes_by_token)[source]¶
Wrap per-frame boxes in the devkit’s
EvalBoxescontainer.
- py123d_detection.core.evaluation.load_predictions(result_path, max_boxes_per_sample, verbose=False)[source]¶
Read a nuScenes-format result JSON into
EvalBoxesofEvalBox.
- py123d_detection.core.evaluation.add_center_distances(eval_boxes, ego_translations)[source]¶
Fill in each box’s offset from its frame’s ego position, in place.
The devkit’s
add_center_distreads the ego pose from a nuScenes database; here it comes from the frame itself.- Return type:
- py123d_detection.core.evaluation.filter_eval_boxes(eval_boxes, max_dist)[source]¶
The devkit’s
filter_eval_boxeswithout the bike-rack step.Drops boxes beyond their class radius, and boxes explicitly recorded as having zero lidar points. A count of
-1means the dataset does not record one, and is kept.
- py123d_detection.core.evaluation.evaluate(ground_truth, predictions, class_names, ego_translations, output_dir=None, class_range=None, eval_version='detection_cvpr_2019', tp_metrics='nuscenes', verbose=True)[source]¶
Score predictions against ground truth, following
DetectionEval.evaluate.- Parameters:
ground_truth (
Mapping[str,Iterable[EvalBox]]) – Boxes per frame token, in the global frame. Every evaluated frame needs an entry even when it has no box, or the frames a model failed on vanish from recall.predictions – Either the same mapping shape, or an
EvalBoxesfromload_predictions().ego_translations (
Mapping[str,ndarray]) – Ego position per frame token.tp_metrics (
str) – A key ofTP_METRIC_SETS.
- Raises:
AssertionError – if the prediction and ground-truth frames differ. Scoring a subset silently inflates recall, which is the one mistake this metric cannot show you.
- Return type:
- Returns:
The devkit’s serialized metrics plus
evaluationdescribing how they were made.