Shortcuts

mmedit.models.data_preprocessors.mattor_preprocessor

Module Contents

Classes

MattorPreprocessor

DataPreprocessor for matting models.

Attributes

DataSamples

ForwardResults

mmedit.models.data_preprocessors.mattor_preprocessor.DataSamples[source]
mmedit.models.data_preprocessors.mattor_preprocessor.ForwardResults[source]
class mmedit.models.data_preprocessors.mattor_preprocessor.MattorPreprocessor(mean: float = [123.675, 116.28, 103.53], std: float = [58.395, 57.12, 57.375], bgr_to_rgb: bool = True, proc_inputs: str = 'normalize', proc_trimap: str = 'rescale_to_zero_one', proc_gt: str = 'rescale_to_zero_one')[source]

Bases: mmengine.model.BaseDataPreprocessor

DataPreprocessor for matting models.

See base class BaseDataPreprocessor 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.

Parameters
  • mean (Sequence[float or int]) – The pixel mean of R, G, B channels. Defaults to [123.675, 116.28, 103.53].

  • std (Sequence[float or int]) – The pixel standard deviation of R, G, B channels. [58.395, 57.12, 57.375].

  • bgr_to_rgb (bool) – whether to convert image from BGR to RGB. Defaults to True.

  • proc_inputs (str) – Methods to process inputs. Default: ‘normalize’. Available options are normalize.

  • proc_trimap (str) – Methods to process gt tensors. Default: ‘rescale_to_zero_one’. Available options are rescale_to_zero_one and as-is.

  • proc_gt (str) – Methods to process gt tensors. Default: ‘rescale_to_zero_one’. Available options are rescale_to_zero_one and ignore.

_proc_inputs(inputs: List[torch.Tensor])[source]
_proc_trimap(trimaps: List[torch.Tensor])[source]
_proc_gt(data_samples, key)[source]
forward(data: Sequence[dict], training: bool = False) Tuple[torch.Tensor, list][source]

Pre-process input images, trimaps, ground-truth as configured.

Parameters
  • data (Sequence[dict]) – data sampled from dataloader.

  • training (bool) – Whether to enable training time augmentation. Default: False.

Returns

Batched inputs and list of data samples.

Return type

Tuple[torch.Tensor, list]

collate_data(data: Sequence[dict]) Tuple[list, list, list][source]

Collating and moving data to the target device.

See base class BaseDataPreprocessor for detailed information.

Read the Docs v: latest
Versions
master
latest
stable
zyh-re-docs
zyh-doc-notfound-extend
zyh-api-rendering
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.