anomalib.utils.callbacks.timer

Callback to measure training and testing time of a PyTorch Lightning module.

Module Contents

Classes

TimerCallback

Callback that measures the training and testing time of a PyTorch Lightning module.

Attributes

anomalib.utils.callbacks.timer.logger[source]
class anomalib.utils.callbacks.timer.TimerCallback[source]

Bases: pytorch_lightning.Callback

Callback that measures the training and testing time of a PyTorch Lightning module.

on_fit_start(trainer: pytorch_lightning.Trainer, pl_module: pytorch_lightning.LightningModule) None[source]

Call when fit begins.

Sets the start time to the time training started.

Parameters
  • trainer (Trainer) – PyTorch Lightning trainer.

  • pl_module (LightningModule) – Current training module.

Returns

None

on_fit_end(trainer: pytorch_lightning.Trainer, pl_module: pytorch_lightning.LightningModule) None[source]

Call when fit ends.

Prints the time taken for training.

Parameters
  • trainer (Trainer) – PyTorch Lightning trainer.

  • pl_module (LightningModule) – Current training module.

Returns

None

on_test_start(trainer: pytorch_lightning.Trainer, pl_module: pytorch_lightning.LightningModule) None[source]

Call when the test begins.

Sets the start time to the time testing started. Goes over all the test dataloaders and adds the number of images in each.

Parameters
  • trainer (Trainer) – PyTorch Lightning trainer.

  • pl_module (LightningModule) – Current training module.

Returns

None

on_test_end(trainer: pytorch_lightning.Trainer, pl_module: pytorch_lightning.LightningModule) None[source]

Call when the test ends.

Prints the time taken for testing and the throughput in frames per second.

Parameters
  • trainer (Trainer) – PyTorch Lightning trainer.

  • pl_module (LightningModule) – Current training module.

Returns

None