:py:mod:`anomalib.models.dfkde` =============================== .. py:module:: anomalib.models.dfkde .. autoapi-nested-parse:: Deep Feature Kernel Density Estimation model. Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 lightning_model/index.rst torch_model/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: anomalib.models.dfkde.Dfkde anomalib.models.dfkde.DfkdeLightning .. py:class:: Dfkde(backbone: str, 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 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(self, 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(self) -> None Fit a KDE Model to the embedding collected from the training set. .. py:method:: validation_step(self, 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]