Shortcuts

mmedit.datasets.transforms.formatting

Module Contents

Classes

PackEditInputs

Pack the inputs data for SR, VFI, matting and inpainting.

ToTensor

Convert some values in results dict to torch.Tensor type in data

Functions

check_if_image(→ bool)

Check if the input value is image or images.

image_to_tensor(img)

Trans image to tensor.

images_to_tensor(value)

Trans image and sequence of frames to tensor.

can_convert_to_image(value)

Judge whether the input value can be converted to image tensor via

mmedit.datasets.transforms.formatting.check_if_image(value: Any) bool[源代码]

Check if the input value is image or images.

If value is a list or Tuple, recursively check if each element in value is image.

参数

value (Any) – The value to be checked.

返回

If the value is image or sequence of images.

返回类型

bool

mmedit.datasets.transforms.formatting.image_to_tensor(img)[源代码]

Trans image to tensor.

参数

img (np.ndarray) – The original image.

返回

The output tensor.

返回类型

Tensor

mmedit.datasets.transforms.formatting.images_to_tensor(value)[源代码]

Trans image and sequence of frames to tensor.

参数

value (np.ndarray | list[np.ndarray] | Tuple[np.ndarray]) – The original image or list of frames.

返回

The output tensor.

返回类型

Tensor

mmedit.datasets.transforms.formatting.can_convert_to_image(value)[源代码]

Judge whether the input value can be converted to image tensor via images_to_tensor() function.

参数

value (any) – The input value.

返回

If true, the input value can convert to image with

images_to_tensor(), and vice versa.

返回类型

bool

class mmedit.datasets.transforms.formatting.PackEditInputs(keys: Tuple[List[str], str, None] = None, pack_all: bool = False)[源代码]

Bases: mmcv.transforms.base.BaseTransform

Pack the inputs data for SR, VFI, matting and inpainting.

Keys for images include img, gt, ref, mask, gt_heatmap,

trimap, gt_alpha, gt_fg, gt_bg. All of them will be packed into data field of EditDataSample.

pack_all (bool): Whether pack all variables in results to inputs dict.

This is useful when keys of the input dict is not fixed. Please be careful when using this function, because we do not Defaults to False.

Others will be packed into metainfo field of EditDataSample.

transform(results: dict) dict[源代码]

Method to pack the input data.

参数

results (dict) – Result dict from the data pipeline.

返回

  • ‘inputs’ (obj:torch.Tensor): The forward data of models.

  • ’data_samples’ (obj:EditDataSample): The annotation info of the

    sample.

返回类型

dict

__repr__() str[源代码]

Return repr(self).

class mmedit.datasets.transforms.formatting.ToTensor(keys, to_float32=True)[源代码]

Bases: mmcv.transforms.base.BaseTransform

Convert some values in results dict to torch.Tensor type in data loader pipeline.

参数
  • keys (Sequence[str]) – Required keys to be converted.

  • to_float32 (bool) – Whether convert tensors of images to float32. Default: True.

_data_to_tensor(value)[源代码]

Convert the value to tensor.

transform(results)[源代码]

transform function.

参数

results (dict) – A dict containing the necessary information and data for augmentation.

返回

A dict containing the processed data and information.

返回类型

dict

__repr__()[源代码]

Return repr(self).

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

Free document hosting provided by Read the Docs.