anomalib.models.stfpm.torch_model

PyTorch model for the STFPM model implementation.

Module Contents

Classes

STFPMModel

STFPM: Student-Teacher Feature Pyramid Matching for Unsupervised Anomaly Detection.

class anomalib.models.stfpm.torch_model.STFPMModel(layers: List[str], input_size: Tuple[int, int], backbone: str = 'resnet18')[source]

Bases: torch.nn.Module

STFPM: Student-Teacher Feature Pyramid Matching for Unsupervised Anomaly Detection.

Parameters
  • layers (List[str]) – Layers used for feature extraction

  • input_size (Tuple[int, int]) – Input size for the model.

  • backbone (str, optional) – Pre-trained model backbone. Defaults to “resnet18”.

forward(images)[source]

Forward-pass images into the network.

During the training mode the model extracts the features from the teacher and student networks. During the evaluation mode, it returns the predicted anomaly map.

Parameters

images (Tensor) – Batch of images.

Returns

Teacher and student features when in training mode, otherwise the predicted anomaly maps.