anomalib.models.patchcore¶
PatchCore model.
Submodules¶
Package Contents¶
Classes¶
PatchcoreLightning Module to train PatchCore algorithm. |
|
PatchcoreLightning Module to train PatchCore algorithm. |
- class anomalib.models.patchcore.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)[source]¶
Bases:
anomalib.models.components.AnomalyModulePatchcoreLightning Module to train PatchCore algorithm.
- Parameters
input_size (Tuple[int, int]) – Size of the model input.
backbone (str) – Backbone CNN network
layers (List[str]) – Layers to extract features from the backbone CNN
pre_trained (bool, optional) – Boolean to check whether to use a pre_trained backbone.
coreset_sampling_ratio (float, optional) – Coreset sampling ratio to subsample embedding. Defaults to 0.1.
num_neighbors (int, optional) – Number of nearest neighbors. Defaults to 9.
- configure_optimizers() None¶
Configure optimizers.
- Returns
Do not set optimizers by returning None.
- Return type
None
- training_step(batch, _batch_idx)¶
Generate feature embedding of the batch.
- Parameters
batch (Dict[str, Any]) – Batch containing image filename, image, label and mask
_batch_idx (int) – Batch Index
- Returns
Embedding Vector
- Return type
Dict[str, np.ndarray]
- on_validation_start() None¶
Apply subsampling to the embedding collected from the training set.
- validation_step(batch, _)¶
Get batch of anomaly maps from input image batch.
- Parameters
batch (Dict[str, Any]) – Batch containing image filename, image, label and mask
_ (int) – Batch Index
- Returns
Image filenames, test images, GT and predicted label/masks
- Return type
Dict[str, Any]