otx.algorithms.anomaly.adapters.anomalib.callbacks#

Callbacks for OTX inference.

Classes

AnomalyInferenceCallback(otx_dataset, ...)

Callback that updates the OTX dataset during inference.

IterationTimer([prog_bar, on_step, on_epoch])

Timer for logging iteration time for train, val, and test phases.

ProgressCallback([parameters])

Progress Callback.

class otx.algorithms.anomaly.adapters.anomalib.callbacks.AnomalyInferenceCallback(otx_dataset: DatasetEntity, labels: List[LabelEntity], task_type: TaskType)[source]#

Bases: Callback

Callback that updates the OTX dataset during inference.

on_predict_epoch_end(_trainer: Trainer, _pl_module: AnomalyModule, outputs: List[Any])[source]#

Call when the predict epoch ends.

class otx.algorithms.anomaly.adapters.anomalib.callbacks.IterationTimer(prog_bar: bool = True, on_step: bool = True, on_epoch: bool = True)[source]#

Bases: Callback

Timer for logging iteration time for train, val, and test phases.

on_test_batch_end(trainer: Trainer, pl_module: LightningModule, outputs: Tensor | Dict[str, Any], batch: Any, batch_idx: int, dataloader_idx: int = 0) None[source]#

Log iteration time on the test batch end.

on_test_batch_start(trainer: Trainer, pl_module: LightningModule, batch: Any, batch_idx: int, dataloader_idx: int = 0) None[source]#

Log iteration data time on the test batch start.

on_test_epoch_start(trainer: Trainer, pl_module: LightningModule) None[source]#

Reset timer before every test epoch starts.

on_train_batch_end(trainer: Trainer, pl_module: LightningModule, outputs: Tensor | Dict[str, Any], batch: Any, batch_idx: int) None[source]#

Log iteration time on the training batch end.

on_train_batch_start(trainer: Trainer, pl_module: LightningModule, batch: Any, batch_idx: int) None[source]#

Log iteration data time on the training batch start.

on_train_epoch_start(trainer: Trainer, pl_module: LightningModule) None[source]#

Reset timer before every train epoch starts.

on_validation_batch_end(trainer: Trainer, pl_module: LightningModule, outputs: Tensor | Dict[str, Any], batch: Any, batch_idx: int, dataloader_idx: int = 0) None[source]#

Log iteration time on the validation batch end.

on_validation_batch_start(trainer: Trainer, pl_module: LightningModule, batch: Any, batch_idx: int, dataloader_idx: int = 0) None[source]#

Log iteration data time on the validation batch start.

on_validation_epoch_start(trainer: Trainer, pl_module: LightningModule) None[source]#

Reset timer before every validation epoch starts.

class otx.algorithms.anomaly.adapters.anomalib.callbacks.ProgressCallback(parameters: TrainParameters | InferenceParameters | OptimizationParameters | None = None)[source]#

Bases: TQDMProgressBar

Progress Callback.

Modify progress callback to show completion of the entire training step.

on_predict_batch_end(trainer, pl_module, outputs, batch, batch_idx, dataloader_idx)[source]#

Adds prediction completion percentage to the progress bar.

on_predict_start(trainer, pl_module)[source]#

Reset progress bar when prediction starts.

on_test_batch_end(trainer, pl_module, outputs, batch, batch_idx, dataloader_idx)[source]#

Adds testing completion percentage to the progress bar.

on_test_start(trainer, pl_module)[source]#

Reset progress bar when testing starts.

on_train_batch_end(trainer, pl_module, outputs, batch, batch_idx)[source]#

Adds training completion percentage to the progress bar.

on_train_start(trainer, pl_module)[source]#

Store max epochs and current epoch from trainer.

on_validation_epoch_end(trainer, pl_module)[source]#

If score exists in trainer.logged_metrics, report the score.