:py:mod:`anomalib.utils.metrics.aupro` ====================================== .. py:module:: anomalib.utils.metrics.aupro .. autoapi-nested-parse:: Implementation of AUPRO score based on TorchMetrics. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: anomalib.utils.metrics.aupro.AUPRO .. py:class:: AUPRO(compute_on_step: bool = True, dist_sync_on_step: bool = False, process_group: Optional[Any] = None, dist_sync_fn: Callable = None, fpr_limit: float = 0.3) Bases: :py:obj:`torchmetrics.Metric` Area under per region overlap (AUPRO) Metric. .. py:attribute:: is_differentiable :annotation: :bool = False .. py:attribute:: higher_is_better :annotation: :Optional[bool] .. py:attribute:: full_state_update :annotation: :bool = False .. py:attribute:: preds :annotation: :List[torch.Tensor] .. py:attribute:: target :annotation: :List[torch.Tensor] .. py:method:: update(preds: torch.Tensor, target: torch.Tensor) -> None Update state with new values. :param preds: predictions of the model :type preds: Tensor :param target: ground truth targets :type target: Tensor .. py:method:: _compute() -> Tuple[torch.Tensor, torch.Tensor] Compute the pro/fpr value-pairs until the fpr specified by self.fpr_limit. It leverages the fact that the overlap corresponds to the tpr, and thus computes the overall PRO curve by aggregating per-region tpr/fpr values produced by ROC-construction. :raises ValueError: ValueError is raised if self.target doesn't conform with requirements imposed by kornia for connected component analysis. :returns: tuple containing final fpr and tpr values. :rtype: Tuple[Tensor, Tensor] .. py:method:: compute() -> torch.Tensor Fist compute PRO curve, then compute and scale area under the curve. :returns: Value of the AUPRO metric :rtype: Tensor .. py:method:: generate_figure() -> Tuple[matplotlib.figure.Figure, str] Generate a figure containing the PRO curve and the AUPRO. :returns: Tuple containing both the figure and the figure title to be used for logging :rtype: Tuple[Figure, str] .. py:method:: interp1d(old_x: torch.Tensor, old_y: torch.Tensor, new_x: torch.Tensor) -> torch.Tensor :staticmethod: Function to interpolate a 1D signal linearly to new sampling points. :param old_x: original 1-D x values (same size as y) :type old_x: Tensor :param old_y: original 1-D y values (same size as x) :type old_y: Tensor :param new_x: x-values where y should be interpolated at :type new_x: Tensor :returns: y-values at corresponding new_x values. :rtype: Tensor