:py:mod:`anomalib.models.patchcore` =================================== .. py:module:: anomalib.models.patchcore .. autoapi-nested-parse:: PatchCore model. Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 anomaly_map/index.rst lightning_model/index.rst torch_model/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: anomalib.models.patchcore.Patchcore anomalib.models.patchcore.PatchcoreLightning .. py:class:: Patchcore(input_size: Tuple[int, int], backbone: str, layers: List[str], pre_trained: bool = True, coreset_sampling_ratio: float = 0.1, num_neighbors: int = 9) Bases: :py:obj:`anomalib.models.components.AnomalyModule` PatchcoreLightning Module to train PatchCore algorithm. :param input_size: Size of the model input. :type input_size: Tuple[int, int] :param backbone: Backbone CNN network :type backbone: str :param layers: Layers to extract features from the backbone CNN :type layers: List[str] :param pre_trained: Boolean to check whether to use a pre_trained backbone. :type pre_trained: bool, optional :param coreset_sampling_ratio: Coreset sampling ratio to subsample embedding. Defaults to 0.1. :type coreset_sampling_ratio: float, optional :param num_neighbors: Number of nearest neighbors. Defaults to 9. :type num_neighbors: int, optional .. py:method:: configure_optimizers() -> None Configure optimizers. :returns: Do not set optimizers by returning None. :rtype: None .. py:method:: training_step(batch, _batch_idx) Generate feature embedding of the batch. :param batch: Batch containing image filename, image, label and mask :type batch: Dict[str, Any] :param _batch_idx: Batch Index :type _batch_idx: int :returns: Embedding Vector :rtype: Dict[str, np.ndarray] .. py:method:: on_validation_start() -> None Apply subsampling to the embedding collected from the training set. .. py:method:: validation_step(batch, _) Get batch of anomaly maps from input image batch. :param batch: Batch containing image filename, image, label and mask :type batch: Dict[str, Any] :param _: Batch Index :type _: int :returns: Image filenames, test images, GT and predicted label/masks :rtype: Dict[str, Any] .. py:class:: PatchcoreLightning(hparams) Bases: :py:obj:`Patchcore` PatchcoreLightning Module to train PatchCore algorithm. :param hparams: Model params :type hparams: Union[DictConfig, ListConfig]