ClsDataPreprocessor¶
- 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)[源代码]¶
用于分类任务的图像预处理器
Comparing with the
mmengine.model.ImgDataPreprocessor
,It won’t do normalization if
mean
is 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 definedpad_size_divisor
Stack inputs to batch_inputs.
如果输入的 tensor 形状为 (3, H, W),则可以执行 BGR 到 RGB 的通道转换
根据给定的均值和方差对图像进行归一化
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
mmpretrain.models.RandomBatchAugment
.