py123d_detection.torch.evaluate¶
Score a trained checkpoint with the nuScenes detection metric.
py123det-eval experiment=nuscenes evaluation.checkpoint=work_dirs/petr_nuscenes/last.ckpt
The model predicts in the ego frame; the metric measures in the global frame. The conversion happens once here, applied identically to predictions and ground truth, so an error in it cannot flatter the score.
One score per dataset. A mixed nuScenes + Argoverse 2 + Waymo run used to collapse into a
single number, which cannot tell you which dataset regressed. The training loop has always kept
its validation losses apart for exactly that reason, and this now matches it. Set
evaluation.combined=true to additionally score every frame together, which is the number older
runs reported.
Inference holds one frame. Each dataset’s predictions stream to
<output_dir>/<dataset>/predictions.jsonl as they are made, and scoring reads them back. Peak
memory is therefore one dataset’s boxes rather than every dataset’s at once, which is what an
earlier three-split pass died of at 67 GB. It also means a run can be scored again with a
different class range, a different true-positive set or a different box cap, and without the
model: evaluation.rescore_from=<output_dir> skips inference entirely.
Module Attributes
Columns of a decoded box: |
Functions
|
Global-frame boxes as the metric's box type. |
|
One sample of |
|
A token identifying one frame across datasets. |
|
|
|
Score a stream of frames. |
|
Score a predictions file written by a previous run, without the model. |
|
Move ego-frame boxes into the global frame. |
|
Indices of the |
Classes
|
Write each rank's predictions to its own file as they are made. |
- py123d_detection.torch.evaluate.YAW = 6¶
Columns of a decoded box:
[x, y, z, w, l, h, yaw, vx, vy]in the ego frame.
- py123d_detection.torch.evaluate.frame_token(metas)[source]¶
A token identifying one frame across datasets.
- Return type:
- py123d_detection.torch.evaluate.to_global(boxes, ego_pose)[source]¶
Move ego-frame boxes into the global frame.
Centres are transformed by the full pose; yaw picks up only the pose’s rotation about z, and velocity is rotated but not translated, since it is a direction rather than a position.
- Return type:
- py123d_detection.torch.evaluate.as_eval_boxes(boxes, names, token, scores=None)[source]¶
Global-frame boxes as the metric’s box type.
The per-field conversion is done for the whole array at once and handed to the loop as native Python floats. Boxing nine numpy scalars per box cost more than everything else in scoring put together once a split ran to millions of boxes; the arithmetic is unchanged.
- py123d_detection.torch.evaluate.top_scoring(scores, limit)[source]¶
Indices of the
limithighest-scoring boxes, or None to keep every one.The devkit caps a submission at 500 boxes a sample; this branch does not, so the cap is opt-in via
evaluation.max_boxes_per_sampleand off by default. Turning it on changes scores, and numbers already published were produced without it. Applied before the metric’s box objects are built, so the cap saves the memory rather than spending it first.
- py123d_detection.torch.evaluate.frame_from_prediction(item, batch, index, max_boxes_per_sample=None)[source]¶
One sample of
Detector3D.predict_step()’s output, as the record written to disk.The model predicts in the ego frame; this is where predictions and ground truth are moved into the global frame together, by the same call, so an error in the conversion cannot flatter the score. Ground truth is taken from the batch rather than returned by
predict_step, which leaves the model’s inference contract about predictions alone.- Return type:
- class py123d_detection.torch.evaluate.FramePredictionWriter(output_dir, max_boxes_per_sample=None)[source]¶
Bases:
BasePredictionWriterWrite each rank’s predictions to its own file as they are made.
Lightning’s own prediction return path collects every batch on every rank, which is the thing this stage exists to avoid:
Trainer.predict(return_predictions=False)with a per-batch writer keeps the peak at one batch. One file per rank rather than a cross-rank gather, so a rank that dies leaves its share on disk instead of taking the whole run’s output with it.Files are routed by each frame’s own
datasetfield, not bydataloader_idx, so the layout follows the data whether the datasets arrive as separate loaders or one concatenation.
- py123d_detection.torch.evaluate.score_frames(frames, class_names, output_dir=None, class_range=None, tp_metrics='nuscenes')[source]¶
Score a stream of frames.
The metric needs every box of the set at once, so this is where memory peaks: at one dataset’s worth when called per dataset, which is the point of calling it that way.