anomalib.models.dfm¶
Deep Feature Extraction (DFM) model.
Submodules¶
Package Contents¶
Classes¶
DFM: Deep Featured Kernel Density Estimation. |
|
DFM: Deep Featured Kernel Density Estimation. |
- class anomalib.models.dfm.Dfm(backbone: str, layer: str, pooling_kernel_size: int = 4, pca_level: float = 0.97, score_type: str = 'fre')[source]¶
Bases:
anomalib.models.components.AnomalyModuleDFM: Deep Featured Kernel Density Estimation.
- Parameters
backbone (str) – Backbone CNN network
layer (str) – Layer to extract features from the backbone CNN
pooling_kernel_size (int, optional) – Kernel size to pool features extracted from the CNN. Defaults to 4.
pca_level (float, optional) – Ratio from which number of components for PCA are calculated. Defaults to 0.97.
score_type (str, optional) – Scoring type. Options are fre and nll. Defaults to “fre”.
nll – for Gaussian modeling, fre: pca feature reconstruction error
- static configure_optimizers() None¶
DFM doesn’t require optimization, therefore returns no optimizers.
- training_step(self, batch, _)¶
Training Step of DFM.
For each batch, features are extracted from the CNN.
- Parameters
batch (Dict[str, Tensor]) – Input batch
_ – Index of the batch.
- Returns
Deep CNN features.
- on_validation_start(self) None¶
Fit a PCA transformation and a Gaussian model to dataset.
- validation_step(self, batch, _)¶
Validation Step of DFM.
Similar to the training step, features are extracted from the CNN for each batch.
- Parameters
batch (List[Dict[str, Any]]) – Input batch
- Returns
Dictionary containing FRE anomaly scores and ground-truth.