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.
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.
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)
- 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.
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 MultiSensorCallbackConnector(key_mapping)[source]¶
Multi-sensor data connector for the callback.
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:
DictData
- class MultiSensorDataConnector(key_mapping)[source]¶
Data connector for multi-sensor data dict.
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:
- class MultiSensorLossConnector(key_mapping)[source]¶
Multi-sensor Data connector for loss module of the training pipeline.
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:
DictData
- 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]
- 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:
- 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])
- 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)
- 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:
- remap_pred_keys(info, parent_key)[source]¶
Remaps the key of a connection mapping to a new parent key.
- Parameters:
info (SourceKeyDescription) – Description to remap.
parent_key (str) – New parent_key to use.
- Returns:
Description with new key.
- Return type:
Modules
Base data connector to define data structures for data connection. |
|
Data connector for multi-sensor dataset. |
|
Utility functions for the connectors module. |