Shortcuts

BaseDataPreprocessor

class mmengine.model.BaseDataPreprocessor(non_blocking=False)[source]

Base data pre-processor used for copying data to the target device.

Subclasses inherit from BaseDataPreprocessor could override the forward method to implement custom data pre-processing, such as batch-resize, MixUp, or CutMix.

Parameters:

non_blocking (bool) – Whether block current process when transferring data to device. New in version 0.3.0.

Note

Data dictionary returned by dataloader must be a dict and at least contain the inputs key.

cast_data(data)[source]

Copying data to the target device.

Parameters:

data (dict) – Data returned by DataLoader.

Returns:

Inputs and data sample at target device.

Return type:

CollatedResult

cpu(*args, **kwargs)[source]

Overrides this method to set the device

Returns:

The model itself.

Return type:

nn.Module

cuda(*args, **kwargs)[source]

Overrides this method to set the device

Returns:

The model itself.

Return type:

nn.Module

forward(data, training=False)[source]

Preprocesses the data into the model input format.

After the data pre-processing of cast_data(), forward will stack the input tensor list to a batch tensor at the first dimension.

Parameters:
  • data (dict) – Data returned by dataloader

  • training (bool) – Whether to enable training time augmentation.

Returns:

Data in the same format as the model input.

Return type:

dict or list

mlu(*args, **kwargs)[source]

Overrides this method to set the device

Returns:

The model itself.

Return type:

nn.Module

musa(*args, **kwargs)[source]

Overrides this method to set the device

Returns:

The model itself.

Return type:

nn.Module

npu(*args, **kwargs)[source]

Overrides this method to set the device

Returns:

The model itself.

Return type:

nn.Module

to(*args, **kwargs)[source]

Overrides this method to set the device

Returns:

The model itself.

Return type:

nn.Module