class_docstr: Callback that normalizes the image-level and pixel-level anomaly scores using min-max normalization.
class_docstr_tok: ["Callback","that","normalizes","the","image-level","and","pixel-level","anomaly","scores","using","min-max","normalization","."]
docstr: Normalize a batch of predictions.
docstr_tok: ["Normalize","a","batch","of","predictions","."]
code: def _normalize_batch(outputs, pl_module) -> None:
      """Normalize a batch of predictions."""
      image_threshold = pl_module.image_threshold.value.cpu()
      pixel_threshold = pl_module.pixel_threshold.value.cpu()
      stats = pl_module.normalization_metrics.cpu()
      outputs["pred_scores"] = normalize(
          outputs["pred_scores"], image_threshold, stats.min, stats.max
      )
      if "anomaly_maps" in outputs:
          outputs["anomaly_maps"] = normalize(
              outputs["anomaly_maps"],
              pixel_threshold,
              stats.min,
              stats.max,
          )
      if "box_scores" in outputs:
          outputs["box_scores"] = [
              normalize(scores, pixel_threshold, stats.min, stats.max)
              for scores in outputs["box_scores"]
          ]
  
file_path: anomalib/src/anomalib/utils/callbacks/min_max_normalization.py
imports: from __future__ import annotations
  from typing import Any
  import pytorch_lightning
  import torch
  from pytorch_lightning import Callback
  from pytorch_lightning.utilities.types import STEP_OUTPUT
  from anomalib.models.components import AnomalyModule
  from anomalib.post_processing.normalization.min_max import normalize
  from anomalib.utils.metrics import MinMax
label_desc: Use image node_id 6 for calling the MinMaxNormalizationCallback obj's underlying member method code with example usage: obj._normalize_batch(outputs, pl_module) without return types