Shortcuts

mmedit.models.utils.tensor_utils

Module Contents

Functions

get_unknown_tensor(trimap[, unknown_value])

Get 1-channel unknown area tensor from the 3 or 1-channel trimap tensor.

normalize_vecs(→ torch.Tensor)

Normalize vector with it's lengths at the last dimension. If vector is

mmedit.models.utils.tensor_utils.get_unknown_tensor(trimap, unknown_value=128 / 255)[源代码]

Get 1-channel unknown area tensor from the 3 or 1-channel trimap tensor.

参数
  • trimap (Tensor) – Tensor with shape (N, 3, H, W) or (N, 1, H, W).

  • unknown_value (float) – Scalar value indicating unknown region in trimap. If trimap is pre-processed using ‘rescale_to_zero_one’, then 0 for bg, 128/255 for unknown, 1 for fg, and unknown_value should set to 128 / 255. If trimap is pre-processed by FormatTrimap(to_onehot=False)(), then 0 for bg, 1 for unknown, 2 for fg and unknown_value should set to 1. If trimap is pre-processed by FormatTrimap(to_onehot=True)(), then trimap is 3-channeled, and this value is not used.

返回

Unknown area mask of shape (N, 1, H, W).

返回类型

Tensor

mmedit.models.utils.tensor_utils.normalize_vecs(vectors: torch.Tensor) torch.Tensor[源代码]

Normalize vector with it’s lengths at the last dimension. If vector is two-dimension tensor, this function is same as L2 normalization.

参数

vector (torch.Tensor) – Vectors to be normalized.

返回

Vectors after normalization.

返回类型

torch.Tensor

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.