vis4d.engine.callbacks.base

Base module for callbacks.

Classes

Callback([epoch_based, train_connector, ...])

Base class for Callbacks.

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.

setup(trainer, pl_module, stage)[source]

Setup callback.

Return type:

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.