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: a Patch Distribution Modeling Framework for Anomaly Detection and Localization. |
|
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, pre_trained: bool = True)[source]¶
Bases:
anomalib.models.components.AnomalyModulePaDiM: 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
pre_trained (bool, optional) – Boolean to check whether to use a pre_trained backbone.
- static configure_optimizers()[source]¶
PADIM doesn’t require optimization, therefore returns no optimizers.
- training_step(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() None[source]¶
Fit a Gaussian to the embedding collected from the training set.
- validation_step(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.