vis4d.engine.callbacks
Callback modules.
- class Callback(epoch_based=True, train_connector=None, test_connector=None)[source]
Base class for Callbacks.
- __init__(epoch_based=True, train_connector=None, test_connector=None)[source]
Init callback.
- Parameters:
epoch_based (bool, optional) – Whether the callback is epoch based. Defaults to False.
train_connector (None | CallbackConnector, optional) – Defines which kwargs to use during training for different callbacks. Defaults to None.
test_connector (None | CallbackConnector, optional) – Defines which kwargs to use during testing for different callbacks. Defaults to None.
- get_train_callback_inputs(outputs, batch)[source]
Returns the data connector results for training.
It extracts the required data from prediction and datas and passes it to the next component with the provided new key.
- Parameters:
outputs (DictData) – Outputs of the model.
batch (DictData) – Batch data.
- Returns:
Data connector results.
- Return type:
dict[str, Tensor | DictStrArrNested]
- Raises:
AssertionError – If train connector is None.
- get_test_callback_inputs(outputs, batch)[source]
Returns the data connector results for inference.
It extracts the required data from prediction and datas and passes it to the next component with the provided new key.
- Parameters:
outputs (DictData) – Outputs of the model.
batch (DictData) – Batch data.
- Returns:
Data connector results.
- Return type:
dict[str, Tensor | DictStrArrNested]
- Raises:
AssertionError – If test connector is None.
- class EMACallback(epoch_based=True, train_connector=None, test_connector=None)[source]
Callback for EMA.
- class EvaluatorCallback(*args, evaluator, metrics_to_eval=None, save_predictions=False, save_prefix=None, output_dir=None, **kwargs)[source]
Callback for model evaluation.
- __init__(*args, evaluator, metrics_to_eval=None, save_predictions=False, save_prefix=None, output_dir=None, **kwargs)[source]
Init callback.
- Parameters:
evaluator (Evaluator) – Evaluator.
metrics_to_eval (list[str], Optional) – Metrics to evaluate. If None, all metrics in the evaluator will be evaluated. Defaults to None.
save_predictions (bool) – If the predictions should be saved. Defaults to False.
save_prefix (str, Optional) – Output directory for saving the evaluation results. Defaults to None.
output_dir (str, Optional) – Output directory for saving the evaluation results.
- on_validation_batch_end(trainer, pl_module, outputs, batch, batch_idx, dataloader_idx=0)[source]
Hook to run at the end of a validation batch.
- Return type:
None
- on_validation_epoch_end(trainer, pl_module)[source]
Wait for on_validation_epoch_end PL hook to call ‘evaluate’.
- Return type:
None
- on_test_batch_end(trainer, pl_module, outputs, batch, batch_idx, dataloader_idx=0)[source]
Hook to run at the end of a testing batch.
- Return type:
None
- on_test_epoch_end(trainer, pl_module)[source]
Hook to run at the end of a testing epoch.
- Return type:
None
- class LoggingCallback(*args, refresh_rate=50, **kwargs)[source]
Callback for logging.
- on_train_epoch_start(trainer, pl_module)[source]
Hook to run at the start of a training epoch.
- Return type:
None
- on_train_batch_start(trainer, pl_module, batch, batch_idx)[source]
Hook to run at the start of a training batch.
- Return type:
None
- on_train_batch_end(trainer, pl_module, outputs, batch, batch_idx)[source]
Hook to run at the end of a training batch.
- Return type:
None
- on_validation_epoch_start(trainer, pl_module)[source]
Hook to run at the start of a validation epoch.
- Return type:
None
- on_validation_batch_end(trainer, pl_module, outputs, batch, batch_idx, dataloader_idx=0)[source]
Wait for on_validation_batch_end PL hook to call ‘process’.
- Return type:
None
- class VisualizerCallback(*args, visualizer, visualize_train=False, show=False, save_to_disk=True, save_prefix=None, output_dir=None, **kwargs)[source]
Callback for model visualization.
- __init__(*args, visualizer, visualize_train=False, show=False, save_to_disk=True, save_prefix=None, output_dir=None, **kwargs)[source]
Init callback.
- Parameters:
visualizer (Visualizer) – Visualizer.
visualize_train (bool) – If the training data should be visualized. Defaults to False.
show (bool) – If the visualizations should be shown. Defaults to False.
save_to_disk (bool) – If the visualizations should be saved to disk. Defaults to True.
save_prefix (str) – Output directory prefix for distinguish different visualizations.
output_dir (str) – Output directory for saving the visualizations.
- on_train_batch_end(trainer, pl_module, outputs, batch, batch_idx)[source]
Hook to run at the end of a training batch.
- Return type:
None
- on_validation_batch_end(trainer, pl_module, outputs, batch, batch_idx, dataloader_idx=0)[source]
Hook to run at the end of a validation batch.
- Return type:
None
- class YOLOXModeSwitchCallback(*args, switch_epoch, **kwargs)[source]
Callback for switching the mode of YOLOX training.
- class YOLOXSyncNormCallback(epoch_based=True, train_connector=None, test_connector=None)[source]
Callback for syncing the norm states of YOLOX training.
- class YOLOXSyncRandomResizeCallback(*args, size_list, interval, **kwargs)[source]
Callback for syncing random resize during YOLOX training.
Modules
Base module for callbacks. |
|
Callback for updating EMA model. |
|
This module contains utilities for callbacks. |
|
This module contains utilities for callbacks. |
|
Callback to configure learning rate during training. |
|
PyTorch Lightning callbacks utilities. |
|
This module contains utilities for callbacks. |
|
YOLOX-specific callbacks. |