anomalib.models.padim.lightning_model

PaDiM: a Patch Distribution Modeling Framework for Anomaly Detection and Localization.

Paper https://arxiv.org/abs/2011.08785

Module Contents

Classes

Padim

PaDiM: a Patch Distribution Modeling Framework for Anomaly Detection and Localization.

PadimLightning

PaDiM: a Patch Distribution Modeling Framework for Anomaly Detection and Localization.

class anomalib.models.padim.lightning_model.Padim(layers: List[str], input_size: Tuple[int, int], backbone: str)[source]

Bases: anomalib.models.components.AnomalyModule

PaDiM: a Patch Distribution Modeling Framework for Anomaly Detection and Localization.

Parameters
  • layers (List[str]) – Layers to extract features from the backbone CNN

  • input_size (Tuple[int, int]) – Size of the model input.

  • backbone (str) – Backbone CNN network

static configure_optimizers()[source]

PADIM doesn’t require optimization, therefore returns no optimizers.

training_step(self, batch, _batch_idx)[source]

Training Step of PADIM. For each batch, hierarchical features are extracted from the CNN.

Parameters
  • batch (Dict[str, Any]) – Batch containing image filename, image, label and mask

  • _batch_idx – Index of the batch.

Returns

Hierarchical feature map

on_validation_start(self) None[source]

Fit a Gaussian to the embedding collected from the training set.

validation_step(self, batch, _)[source]

Validation Step of PADIM.

Similar to the training step, hierarchical features are extracted from the CNN for each batch.

Parameters
  • batch – Input batch

  • _ – Index of the batch.

Returns

Dictionary containing images, features, true labels and masks. These are required in validation_epoch_end for feature concatenation.

class anomalib.models.padim.lightning_model.PadimLightning(hparams: Union[omegaconf.DictConfig, omegaconf.ListConfig])[source]

Bases: Padim

PaDiM: a Patch Distribution Modeling Framework for Anomaly Detection and Localization.

Parameters

hparams (Union[DictConfig, ListConfig]) – Model params