mmedit.datasets.transforms.formatting¶
Module Contents¶
Classes¶
Pack the inputs data for SR, VFI, matting and inpainting. |
|
Convert some values in results dict to torch.Tensor type in data |
Functions¶
|
Check if the input value is image or images. |
|
Trans image to tensor. |
|
Trans image and sequence of frames to tensor. |
|
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
valueis 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.BaseTransformPack 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.
- Keys for images include
- class mmedit.datasets.transforms.formatting.ToTensor(keys, to_float32=True)[源代码]¶
Bases:
mmcv.transforms.base.BaseTransformConvert 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.