kornia.utils.metrics¶

confusion_matrix
(input: torch.Tensor, target: torch.Tensor, num_classes: int, normalized: Optional[bool] = False) → torch.Tensor[source]¶ Compute confusion matrix to evaluate the accuracy of a classification.
 Parameters
input (torch.Tensor) – tensor with estimated targets returned by a classifier. The shape can be \((B, *)\) and must contain integer values between 0 and K1.
target (torch.Tensor) – tensor with ground truth (correct) target values. The shape can be \((B, *)\) and must contain integer values between 0 and K1, whete targets are assumed to be provided as onehot vectors.
num_classes (int) – total possible number of classes in target.
normalized – (Optional[bool]): wether to return the confusion matrix normalized. Default: False.
 Returns
a tensor containing the confusion matrix with shape \((B, K, K)\) where K is the number of classes.
 Return type

mean_iou
(input: torch.Tensor, target: torch.Tensor, num_classes: int, eps: Optional[float] = 1e06) → torch.Tensor[source]¶ Calculate mean IntersectionOverUnion (mIOU).
The function internally computes the confusion matrix.
 Parameters
input (torch.Tensor) – tensor with estimated targets returned by a classifier. The shape can be \((B, *)\) and must contain integer values between 0 and K1.
target (torch.Tensor) – tensor with ground truth (correct) target values. The shape can be \((B, *)\) and must contain integer values between 0 and K1, whete targets are assumed to be provided as onehot vectors.
num_classes (int) – total possible number of classes in target.
 Returns
a tensor representing the mean intersectionover union with shape \((B, K)\) where K is the number of classes.
 Return type