anomalib.utils.metrics.pro¶
Implementation of PRO metric based on TorchMetrics.
Module Contents¶
Classes¶
Per-Region Overlap (PRO) Score. |
Functions¶
|
Calculate the PRO score for a batch of predictions. |
|
Perform connected component labeling on GPU and remap the labels from 0 to N. |
|
Connected component labeling on CPU. |
- class anomalib.utils.metrics.pro.PRO(threshold: float = 0.5, **kwargs)[source]¶
Bases:
torchmetrics.MetricPer-Region Overlap (PRO) Score.
- anomalib.utils.metrics.pro.pro_score(predictions: torch.Tensor, comps: torch.Tensor, threshold: float = 0.5) torch.Tensor[source]¶
Calculate the PRO score for a batch of predictions.
- Parameters
predictions (Tensor) – Predicted anomaly masks (Bx1xHxW)
comps – (Tensor): Labeled connected components (BxHxW). The components should be labeled from 0 to N
threshold (float) – When predictions are passed as float, the threshold is used to binarize the predictions.
- Returns
Scalar value representing the average PRO score for the input batch.
- Return type
Tensor
- anomalib.utils.metrics.pro.connected_components_gpu(binary_input: torch.Tensor, num_iterations: int = 1000) torch.Tensor[source]¶
Perform connected component labeling on GPU and remap the labels from 0 to N.
- Parameters
binary_input (Tensor) – Binary input data from which we want to extract connected components (Bx1xHxW)
num_iterations (int) – Number of iterations used in the connected component computation.
- Returns
Components labeled from 0 to N.
- Return type
Tensor