# Looking at what the model found An evaluation gives you one number per dataset. These views show where it came from. ![A nuScenes scene playing through the camera and bird's eye panels](../images/viz-scene.gif) The figures here come from one `predictions.jsonl`, a PETR checkpoint scored on two nuScenes validation scenes. It was trained on a single `vehicle` class, so nothing else is boxed. Everything reads the `predictions.jsonl` that `py123det-eval` writes beside each dataset's metrics, so none of it needs a checkpoint or a GPU. Install the extra first: ```bash pip install -e "py123d_detection[viz]" ``` ## From above ```bash py123det-viz bev work_dirs/petr_nuscenes_10cls/eval/nuscenes/predictions.jsonl -o frames/ ``` ![Bird's eye view of one frame](../images/viz-bev.png) Ground truth is filled orange, predictions are hollow blue, and a prediction fades to grey as its score drops. Filled against hollow still reads at thumbnail size where colour alone does not. The layout is the thesis's so the two are comparable. Forward is up, range rings sit at 10, 25 and 50 m, and a tick runs from each box's centre to its leading edge for heading. A box whose centre leaves the window is dropped rather than clipped. This needs nothing but the file. The boxes in it are global and the view puts them back into the ego frame. | | | | --- | --- | | `--score-threshold` | default 0.3. A detector emits one box per query, 900 in the shipped configs, so an unfiltered view is a solid block. | | `--limit` | frames to render, default 20. | | `--dataset` | only frames of one dataset, for a file covering several. | | `--radius` | half-width of the view in metres, default 50. | | `--taxonomy` | name classes in the legend. The config group `nuscenes_10cls` and the registry name `nuscenes_detection_10cls` both work. | ## The front camera beside it ```bash py123det-viz frame .../predictions.jsonl -o frames/ --experiment nuscenes_av2_wod ``` ![The front camera and the bird's eye view of one frame](../images/viz-frame.png) `--camera` picks another camera of the rig. 0, the default, is the front one in every rig. ## On every camera image ```bash py123det-viz cameras .../predictions.jsonl -o frames/ --experiment nuscenes_av2_wod ``` ![Six cameras of one frame, tiled](../images/viz-cameras.jpg) Use this instead of `frame` when the interesting object is not in front. These need the 123D logs too, since the file holds boxes and not pixels. `--experiment` says which dataset to take them from. For a config that does not live in the package, point Hydra at it with `-O 'hydra.searchpath=[file:///path/to/conf]'`. An edge is drawn only where both of its corners project in front of the camera and inside the frame, so a box leaving the view comes out partly drawn. ## In the interactive viewer ```bash py123det-view work_dirs/petr_nuscenes_10cls/eval/nuscenes/predictions.jsonl --split nuscenes_val ``` ![The viewer playing a nuScenes scene](../images/viz-viewer.gif) The blue wireframes are the model's boxes. The rest is py123d's viewer, and the controls for ours are under Predictions in the panel. | | | | --- | --- | | `--split` | 123D split to find the logs in, `nuscenes_val` here. Repeatable. Without it every split under the data root is searched, which is slower. | | `--data-root` | 123D root holding `logs/`, default `$PY123D_DATA_ROOT`. | | `--frame-stride` | the stride the run was *evaluated* with, which is what its frame numbers mean. Default is every frame, and a mismatch puts the boxes on the wrong ones. | | `--score-threshold` | where the score slider starts, default 0.3. | | `--ground-truth` | draw the run's filtered ground truth as well. | | `--max-scenes` | open at most this many logs. | | `--dataset` | only frames of one dataset. | | `--host`, `--port` | default `localhost:8080`. | `tools/capture_viewer.py` takes the same arguments and writes two PNGs, one with the ground truth overlay and one without, so a pair can be compared: ```bash python tools/capture_viewer.py .../predictions.jsonl --split nuscenes_val -o docs/images ``` ## From Python The rendering is ordinary functions, so a notebook or a script can use them directly: ```python from py123d_detection.torch.predictions import read_predictions from py123d_detection.torch.visualize import render_bev, render_camera for frame in read_predictions("eval/nuscenes/predictions.jsonl"): figure = render_bev(frame, score_threshold=0.4) ... ``` `render_camera(image, imu2img, predictions, ground_truth=..., scores=...)` draws onto one camera image and returns a new array. `tile` lays a rig's cameras out in a grid, padding rather than assuming they share a resolution, because Argoverse 2's do not. The conversion into py123d's own types is public too: ```python from py123d_detection.core.taxonomy import get_taxonomy from py123d_detection.torch.visualize import add_to_viser, frames_by_token, tokens_in_order, to_detections taxonomy = get_taxonomy("general_3cls") frames = frames_by_token("eval/nuscenes/predictions.jsonl") # As py123d's own type, for anything in its visualisation stack: detections = to_detections(frames[":118"], taxonomy, score_threshold=0.4) # Or straight onto a running viser server, as a wireframe overlay: handle = add_to_viser(server, frames[":118"], score_threshold=0.4) ``` `tokens_in_order` sorts tokens by frame number rather than as text. `add_to_viser` takes an `origin` because py123d draws a scene relative to its centre, and an overlay that skips it lands hundreds of metres away. py123d's label vocabulary is coarse on purpose, `VEHICLE` and `TWO_WHEELER` rather than car, truck and bus, so a fine grained taxonomy cannot round-trip through it. `mixed_8cls` loses four of its eight classes and `nuscenes_detection_10cls` all ten. Those boxes still draw, as `GENERIC_OBJECT`, they just stop being told apart by colour. `unmapped_classes(taxonomy)` says which classes are affected. ## A note on matplotlib The `viz` extra needs matplotlib 3.8 or newer. Older versions raise on `np.Inf`, which NumPy 2.0 removed, inside matplotlib's own title positioning. If a render fails with that error, the matplotlib in your environment is too old for its numpy.