:py:mod:`anomalib.models.padim` =============================== .. py:module:: anomalib.models.padim .. autoapi-nested-parse:: PADIM model. Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 anomaly_map/index.rst lightning_model/index.rst torch_model/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: anomalib.models.padim.Padim anomalib.models.padim.PadimLightning .. py:class:: Padim(layers: List[str], input_size: Tuple[int, int], backbone: str, pre_trained: bool = True) Bases: :py:obj:`anomalib.models.components.AnomalyModule` PaDiM: a Patch Distribution Modeling Framework for Anomaly Detection and Localization. :param layers: Layers to extract features from the backbone CNN :type layers: List[str] :param input_size: Size of the model input. :type input_size: Tuple[int, int] :param backbone: Backbone CNN network :type backbone: str :param pre_trained: Boolean to check whether to use a pre_trained backbone. :type pre_trained: bool, optional .. py:method:: configure_optimizers() :staticmethod: PADIM doesn't require optimization, therefore returns no optimizers. .. py:method:: training_step(batch, _batch_idx) Training Step of PADIM. For each batch, hierarchical features are extracted from the CNN. :param batch: Batch containing image filename, image, label and mask :type batch: Dict[str, Any] :param _batch_idx: Index of the batch. :returns: Hierarchical feature map .. py:method:: on_validation_start() -> None Fit a Gaussian to the embedding collected from the training set. .. py:method:: validation_step(batch, _) Validation Step of PADIM. Similar to the training step, hierarchical features are extracted from the CNN for each batch. :param batch: Input batch :param _: Index of the batch. :returns: Dictionary containing images, features, true labels and masks. These are required in `validation_epoch_end` for feature concatenation. .. py:class:: PadimLightning(hparams: Union[omegaconf.DictConfig, omegaconf.ListConfig]) Bases: :py:obj:`Padim` PaDiM: a Patch Distribution Modeling Framework for Anomaly Detection and Localization. :param hparams: Model params :type hparams: Union[DictConfig, ListConfig]