vis4d.engine.connectors

Data connector for data connection.

class CallbackConnector(key_mapping)[source]

Data connector for the callback.

It extracts the required data from prediction and datas and passes it to the next component with the provided new key.

__init__(key_mapping)[source]

Initializes the data connector with static remapping of the keys.

__call__(prediction, data)[source]

Returns the kwargs that are passed to the callback.

Parameters:
  • prediction (DictData | NamedTuple) – The output from model.

  • data (DictData) – The data dictionary from the dataloader which contains all data that was loaded.

Returns:

kwargs that are passed

onto the callback.

Return type:

dict[str, Tensor | DictStrArrNested]

class DataConnector(key_mapping)[source]

Defines which data to pass to which component.

It extracts the required data from a ‘DictData’ objects and passes it to the next component with the provided new key.

__init__(key_mapping)[source]

Initializes the data connector with static remapping of the keys.

Parameters:

key_mapping (dict[str, str]) – Defines which kwargs to pass onto the module.

Simple Example Configuration:

>>> train = dict(images = "images", gt = "gt_images)
>>> train_data_connector = DataConnector(train)
>>> test = dict(images = "images")
>>> test_data_connector = DataConnector(test)
__call__(data)[source]

Returns the kwargs that are passed to the module.

Parameters:

data (DictDataorList) – The data (e.g. from the dataloader) which contains all data that was loaded.

Returns:

kwargs that are passed onto the model.

Return type:

DictData

data_key(key, sensors=None)[source]

Returns a SourceKeyDescription with data as source.

Parameters:
  • key (str) – Key to use for the data entry.

  • sensors (Sequence[str] | None, optional) – Which sensors to use for the data. Defaults to None.

Returns:

A SourceKeyDescription with data as source.

Return type:

SourceKeyDescription

get_multi_sensor_inputs(connection_dict, prediction, data)[source]

Extracts multi-sensor input data from the provided SourceKeyDescription.

Parameters:
  • connection_dict (dict[str, SourceKeyDescription]) – Input Key description which is used to gather and remap data from the two data dicts.

  • prediction (DictData) – Dict containing the model prediction output.

  • data (DictData) – Dict containing the dataloader output.

Raises:

ValueError – If the datasource is invalid.

Returns:

Dict containing new kwargs consisting of new key name

and data extracted from the data dicts.

Return type:

out (DictData)

get_inputs_for_pred_and_data(connection_dict, prediction, data)[source]

Extracts input data from the provided SourceKeyDescription.

Parameters:
  • connection_dict (dict[str, SourceKeyDescription]) – Input Key description which is used to gather and remap data from the two data dicts.

  • prediction (DictData) – Dict containing the model prediction output.

  • data (DictData) – Dict containing the dataloader output.

Raises:

ValueError – If the datasource is invalid.

Returns:

Dict containing new kwargs

consisting of new key name and data extracted from the data dicts.

Return type:

out (dict[str, Tensor | DictStrArrNested])

class LossConnector(key_mapping)[source]

Defines which data to pass to loss module of the training pipeline.

It extracts the required data from prediction and data and passes it to the next component with the provided new key.

__init__(key_mapping)[source]

Initializes the data connector with static remapping of the keys.

__call__(prediction, data)[source]

Returns the kwargs that are passed to the loss module.

Parameters:
  • prediction (DictData | NamedTuple) – The output from model.

  • data (DictData) – The data dictionary from the dataloader which contains all data that was loaded.

Returns:

kwargs that are passed

onto the loss.

Return type:

dict[str, Tensor | DictStrArrNested]

class MultiSensorDataConnector(key_mapping)[source]

Data connector for multi-sensor data dict.

__init__(key_mapping)[source]

Initializes the data connector with static remapping of the keys.

Parameters:

key_mapping (dict[str, | SourceKeyDescription]) – Defines which kwargs to pass onto the module.

TODO: Add Simple Example Configuration:

__call__(data)[source]

Returns the train input for the model.

Return type:

Dict[str, Any]

class MultiSensorCallbackConnector(key_mapping)[source]

Multi-sensor data connector for the callback.

__call__(prediction, data)[source]

Returns the kwargs that are passed to the callback.

Parameters:
  • prediction (DictData | NamedTuple) – The output from model.

  • data (DictData) – The data dictionary from the dataloader which contains all data that was loaded.

Returns:

kwargs that are passed onto the callback.

Return type:

DictData

class MultiSensorLossConnector(key_mapping)[source]

Multi-sensor Data connector for loss module of the training pipeline.

__call__(prediction, data)[source]

Returns the kwargs that are passed to the loss module.

Parameters:
  • prediction (DictData | NamedTuple) – The output from model.

  • data (DictData) – The data dictionary from the dataloader which contains all data that was loaded.

Returns:

kwargs that are passed onto the loss.

Return type:

DictData

pred_key(key)[source]

Returns a SourceKeyDescription with prediction as source.

Parameters:

key (str) – Key to use for the data entry.

Returns:

A SourceKeyDescription with prediction as source.

Return type:

SourceKeyDescription

remap_pred_keys(info, parent_key)[source]

Remaps the key of a connection mapping to a new parent key.

Parameters:
Returns:

Description with new key.

Return type:

SourceKeyDescription

class SourceKeyDescription[source]

Defines a data entry by providing the key and source of the data.

key

Key that is used to index data from the specified source

Type:

str

source

Which datasource to choose from. Options are [‘data’, ‘prediction’] where data referes to the output of the dataloader and prediction refers to the model output

Type:

str

sensors

Which sensors to use for the data.

Type:

Sequence[str]

Modules

base

Base data connector to define data structures for data connection.

multi_sensor

Data connector for multi-sensor dataset.

util

Utility functions for the connectors module.