anomalib.models.components.base.anomaly_module¶
Base Anomaly Module for Training Task.
Module Contents¶
Classes¶
AnomalyModule to train, validate, predict and test images. |
Attributes¶
- class anomalib.models.components.base.anomaly_module.AnomalyModule[source]¶
Bases:
pytorch_lightning.LightningModule,abc.ABCAnomalyModule to train, validate, predict and test images.
Acts as a base class for all the Anomaly Modules in the library.
- forward(self, batch)[source]¶
Forward-pass input tensor to the module.
- Parameters
batch (Tensor) – Input Tensor
- Returns
Output tensor from the model.
- Return type
Tensor
- predict_step(self, batch: Any, batch_idx: int, _dataloader_idx: Optional[int] = None) Any[source]¶
Step function called during
predict().By default, it calls
forward(). Override to add any processing logic.- Parameters
batch (Tensor) – Current batch
batch_idx (int) – Index of current batch
_dataloader_idx (int) – Index of the current dataloader
- Returns
Predicted output
- test_step(self, batch, _)[source]¶
Calls validation_step for anomaly map/score calculation.
- Parameters
batch (Tensor) – Input batch
_ – Index of the batch.
- Returns
Dictionary containing images, features, true labels and masks. These are required in validation_epoch_end for feature concatenation.
- validation_epoch_end(self, outputs)[source]¶
Compute threshold and performance metrics.
- Parameters
outputs – Batch of outputs from the validation step