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

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

Read the Docs v: v0.10.0
Versions
latest
stable
v0.10.0
v0.9.1
v0.9.0
v0.8.5
v0.8.4
v0.8.3
v0.8.2
v0.8.1
v0.8.0
v0.7.4
v0.7.3
v0.7.2
v0.7.1
v0.7.0
v0.6.0
v0.5.0
v0.4.0
v0.3.0
v0.2.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.