- class mmpretrain.models.utils.data_preprocessor.ClsDataPreprocessor(mean=None, std=None, pad_size_divisor=1, pad_value=0, to_rgb=False, to_onehot=False, num_classes=None, batch_augments=None)¶
Image pre-processor for classification tasks.
Comparing with the
It won’t do normalization if
meanis not specified.
It does normalization and color space conversion after stacking batch.
It supports batch augmentations like mixup and cutmix.
It provides the data pre-processing as follows
Collate and move data to the target device.
Pad inputs to the maximum size of current batch with defined
pad_value. The padding size can be divisible by a defined
Stack inputs to batch_inputs.
Convert inputs from bgr to rgb if the shape of input is (3, H, W).
Normalize image with defined std and mean.
Do batch augmentations like Mixup and Cutmix during training.
mean (Sequence[Number], optional) – The pixel mean of R, G, B channels. Defaults to None.
std (Sequence[Number], optional) – The pixel standard deviation of R, G, B channels. Defaults to None.
pad_size_divisor (int) – The size of padded image should be divisible by
pad_size_divisor. Defaults to 1.
pad_value (Number) – The padded pixel value. Defaults to 0.
to_rgb (bool) – whether to convert image from BGR to RGB. Defaults to False.
to_onehot (bool) – Whether to generate one-hot format gt-labels and set to data samples. Defaults to False.
num_classes (int, optional) – The number of classes. Defaults to None.
batch_augments (dict, optional) – The batch augmentations settings, including “augments” and “probs”. For more details, see
- forward(data, training=False)¶
Perform normalization, padding, bgr2rgb conversion and batch augmentation based on