plot_boxes

plot_boxes(
    images,
    boxes,
    truth=None,
    which=None,
    min_score=BOX_MIN_SCORE,
    colours=None,
    labels=None,
)

Detections drawn on the images they were found in, one row per image.

Parameters

Name Type Description Default
images np.ndarray one image or a stack. required
boxes list[dict[str, Any]] what DetectionEngine.predict() returned - one record per image, with boxes, labels and scores in that image’s own pixels. required
truth list[dict[str, Any]] | None the annotation in the same shape, drawn in a second colour. None
which list[int] | None which images to draw; the default is the first four. None
min_score float boxes below this are not drawn. Not the engine’s operating_point, which sits near zero so average precision can integrate a whole ranking. BOX_MIN_SCORE
colours dict[str, str] | None keyed prediction and truth; defaults to the engine’s. None
labels list[str] | None a row label each. None

Returns

Name Type Description
Figure A matplotlib Figure.

Raises

Name Type Description
PlatypusError if there is not one record per image.

import numpy as np found = [{“boxes”: [[1, 1, 5, 5]], “labels”: [“cell”], “scores”: [0.91]}] figure = plot_boxes(np.full((1, 8, 8, 3), 0.5), found) len(figure.axes[0].patches), figure.axes[0].texts[0].get_text() (1, ‘cell 0.91’)