mmagic.models.data_preprocessors.mattor_preprocessor
¶
Module Contents¶
Classes¶
DataPreprocessor for matting models. |
Attributes¶
- class mmagic.models.data_preprocessors.mattor_preprocessor.MattorPreprocessor(mean: MEAN_STD_TYPE = [123.675, 116.28, 103.53], std: MEAN_STD_TYPE = [58.395, 57.12, 57.375], output_channel_order: str = 'RGB', proc_trimap: str = 'rescale_to_zero_one', stack_data_sample=True)[源代码]¶
Bases:
mmagic.models.data_preprocessors.data_preprocessor.DataPreprocessor
DataPreprocessor for matting models.
See base class
DataPreprocessor
for detailed information.Workflow as follow :
Collate and move data to the target device.
Convert inputs from bgr to rgb if the shape of input is (3, H, W).
Normalize image with defined std and mean.
Stack inputs to batch_inputs.
- 参数
mean (Sequence[float or int], float or int, optional) – The pixel mean of image channels. Noted that normalization operation is performed after channel order conversion. If it is not specified, images will not be normalized. Defaults None.
std (Sequence[float or int], float or int, optional) – The pixel standard deviation of image channels. Noted that normalization operation is performed after channel order conversion. If it is not specified, images will not be normalized. Defaults None.
proc_trimap (str) – Methods to process gt tensors. Default: ‘rescale_to_zero_one’. Available options are
rescale_to_zero_one
andas-is
.stack_data_sample (bool) – Whether stack a list of data samples to one data sample. Only support with input data samples are DataSamples. Defaults to True.
- _preprocess_data_sample(data_samples: mmagic.utils.typing.SampleList, training: bool) list [源代码]¶
Preprocess data samples. When training is True, fields belong to
self.data_keys
will be converted toself.output_channel_order
and divided by 255. When training is False, fields belongs toself.data_keys
will be attempted to convert to ‘BGR’ without normalization. The corresponding metainfo related to normalization, channel order conversion will be updated to data sample as well.- 参数
data_samples (List[DataSample]) – A list of data samples to preprocess.
training (bool) – Whether in training mode.
- 返回
The list of processed data samples.
- 返回类型
list
- forward(data: Sequence[dict], training: bool = False) Tuple[torch.Tensor, list] [源代码]¶
Pre-process input images, trimaps, ground-truth as configured.
- 参数
data (Sequence[dict]) – data sampled from dataloader.
training (bool) – Whether to enable training time augmentation. Default: False.
- 返回
Batched inputs and list of data samples.
- 返回类型
Tuple[torch.Tensor, list]