TwoNormDataPreprocessor¶
- class mmpretrain.models.utils.data_preprocessor.TwoNormDataPreprocessor(mean=None, std=None, second_mean=None, second_std=None, pad_size_divisor=1, pad_value=0, to_rgb=False, non_blocking=False)[源代码]¶
Image pre-processor for CAE, BEiT v1/v2, etc.
Compared with the
mmselfsup.SelfSupDataPreprocessor
, this module will normalize the prediction image and target image with different normalization parameters.- 参数:
mean (Sequence[float or int], optional) – The pixel mean of image channels. If
to_rgb=True
it means the mean value of R, G, B channels. If the length of mean is 1, it means all channels have the same mean value, or the input is a gray image. If it is not specified, images will not be normalized. Defaults to None.std (Sequence[float or int], optional) – The pixel standard deviation of image channels. If
to_rgb=True
it means the standard deviation of R, G, B channels. If the length of std is 1, it means all channels have the same standard deviation, or the input is a gray image. If it is not specified, images will not be normalized. Defaults to None.second_mean (Sequence[float or int], optional) – The description is like
mean
, it can be customized for targe image. Defaults to None.second_std (Sequence[float or int], optional) – The description is like
std
, it can be customized for targe image. Defaults to None.pad_size_divisor (int) – The size of padded image should be divisible by
pad_size_divisor
. Defaults to 1.pad_value (float or int) – The padded pixel value. Defaults to 0.
to_rgb (bool) – whether to convert image from BGR to RGB. Defaults to False.
non_blocking (bool) – Whether block current process when transferring data to device. Defaults to False.
- forward(data, training=False)[源代码]¶
Performs normalization and bgr2rgb conversion based on
BaseDataPreprocessor
. Thebatch_inputs
in forward function is a list.- 参数:
- 返回:
- Data in the same format as the
model input.
- 返回类型:
Tuple[torch.Tensor, Optional[list]]