:py:mod:`anomalib.models.dfkde.lightning_model` =============================================== .. py:module:: anomalib.models.dfkde.lightning_model .. autoapi-nested-parse:: DFKDE: Deep Feature Kernel Density Estimation. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: anomalib.models.dfkde.lightning_model.Dfkde anomalib.models.dfkde.lightning_model.DfkdeLightning Attributes ~~~~~~~~~~ .. autoapisummary:: anomalib.models.dfkde.lightning_model.logger .. py:data:: logger .. py:class:: Dfkde(layers: List[str], backbone: str, pre_trained: bool = True, max_training_points: int = 40000, pre_processing: str = 'scale', n_components: int = 16, threshold_steepness: float = 0.05, threshold_offset: int = 12) Bases: :py:obj:`anomalib.models.components.AnomalyModule` DFKDE: Deep Feature Kernel Density Estimation. :param backbone: Pre-trained model backbone. :type backbone: str :param pre_trained: Boolean to check whether to use a pre_trained backbone. :type pre_trained: bool, optional :param max_training_points: Number of training points to fit the KDE model. Defaults to 40000. :type max_training_points: int, optional :param pre_processing: Preprocess features before passing to KDE. Options are between `norm` and `scale`. Defaults to "scale". :type pre_processing: str, optional :param n_components: Number of PCA components. Defaults to 16. :type n_components: int, optional :param threshold_steepness: Controls how quickly the value saturates around zero. Defaults to 0.05. :type threshold_steepness: float, optional :param threshold_offset: Offset of the density function from 0. Defaults to 12.0. :type threshold_offset: float, optional .. py:method:: configure_optimizers() :staticmethod: DFKDE doesn't require optimization, therefore returns no optimizers. .. py:method:: training_step(batch, _batch_idx) Training Step of DFKDE. For each batch, 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: Deep CNN features. .. py:method:: on_validation_start() -> None Fit a KDE Model to the embedding collected from the training set. .. py:method:: validation_step(batch, _) Validation Step of DFKDE. Similar to the training step, features are extracted from the CNN for each batch. :param batch: Input batch :returns: Dictionary containing probability, prediction and ground truth values. .. py:class:: DfkdeLightning(hparams: Union[omegaconf.DictConfig, omegaconf.ListConfig]) Bases: :py:obj:`Dfkde` DFKDE: Deep Feature Kernel Density Estimation. :param hparams: Model params :type hparams: Union[DictConfig, ListConfig]