overlay_instance_agreement
overlay_instance_agreement(
image,
prediction,
truth,
threshold=0.5,
alpha=OVERLAY_ALPHA,
colours=None,
)Found, missed and invented objects, matched the way the metric matches them.
overlay_agreement answers the same three-way question about pixels, and on an instance result that is the wrong unit: a merged pair and a split object are both nearly perfect pixelwise and both wrong, which is exactly what an average precision of 0.5587 will not tell anybody. This matches whole objects at one IoU threshold, using iou_matrix - the same function the metric uses - so the picture and the number cannot disagree.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| image | np.ndarray | one image, as overlay_mask takes it. |
required |
| prediction | np.ndarray | an instance label map from a model. | required |
| truth | np.ndarray | an instance label map from the annotation. | required |
| threshold | float | the IoU above which a predicted object counts as a true one, strictly greater as in average_precision. 0.5 is the loosest of the challenge’s ten thresholds, so this is the kindest reading, and below 0.5 is refused for the reason the metric refuses it. |
0.5 |
| alpha | float | how much of the tint shows. | OVERLAY_ALPHA |
| colours | dict[str, str] | None | keyed hit, missed, false_alarm, as overlay_agreement takes them. |
None |
Returns
| Name | Type | Description |
|---|---|---|
| np.ndarray | A height x width x 3 array of 0-255 integers. |
Raises
| Name | Type | Description |
|---|---|---|
| PlatypusError | if the shapes do not correspond, a colour is missing, or the threshold is below 0.5. |
import numpy as np image = np.full((5, 11, 3), 0.5) truth = np.zeros((5, 11), dtype=int) truth[1:4, 1:4] = 1 truth[1:4, 5:8] = 2 predicted = np.zeros((5, 11), dtype=int) predicted[1:4, 1:4] = 1 # one found predicted[1:4, 8:11] = 2 # one invented, and object 2 missed shown = overlay_instance_agreement(image, predicted, truth) hit, missed, invented = shown[2, 2], shown[2, 6], shown[2, 9] bool((hit != missed).any() and (missed != invented).any()) True