vis4d.eval.common.seg

Common segmentation evaluator.

Classes

SegEvaluator([num_classes, class_to_ignore, ...])

Creates an evaluator that calculates mIoU score and confusion matrix.

class SegEvaluator(num_classes=None, class_to_ignore=None, class_mapping=None)[source]

Creates an evaluator that calculates mIoU score and confusion matrix.

Creates a new evaluator.

Parameters:
  • num_classes (int) – Number of semantic classes

  • class_to_ignore (int | None) – Groundtruth class that should be ignored

  • class_mapping (int) – dict mapping each class_id to a readable name

calc_confusion_matrix(prediction, groundtruth)[source]

Calculates the confusion matrix for multi class predictions.

Parameters:
  • prediction (array) – Class predictions

  • groundtruth (array) – Groundtruth classes

Return type:

ndarray[Any, dtype[int64]]

Returns:

Confusion Matrix of dimension n_classes x n_classes.

evaluate(metric)[source]

Evaluate predictions.

Returns a dict containing the raw data and a short description string containing a readable result.

Parameters:

metric (str) – Metric to use. See @property metric.

Return type:

tuple[Dict[str, Union[float, int, Tensor]], str]

Returns:

(dict, str) containing the raw data and a short description string.

Raises:

ValueError – If metric is not supported.

process_batch(prediction, groundtruth)[source]

Process sample and update confusion matrix.

Parameters:
  • prediction (ArrayLike) – Predictions of shape [N,C,…] or [N,…] with C* being any number if channels. Note, C is passed, the prediction is converted to target labels by applying the max operations along the second axis

  • groundtruth (ArrayLike) – Groundtruth of shape [N_batch, …] type int

Return type:

None

reset()[source]

Reset the saved predictions to start new round of evaluation.

Return type:

None

property metrics: list[str]

Supported metrics.