Shortcuts

mmedit.evaluation.metrics.metrics_utils

Module Contents

Functions

_assert_ndim(input, name, ndim, shape_hint)

_assert_masked(pred_alpha, trimap)

_fetch_data_and_check(data_samples)

Fetch and check data from one item of data_batch and predictions.

average(results, key)

Average of key in results(list[dict]).

img_transform(img[, crop_border, input_order, ...])

Image transform.

obtain_data(data_sample, key[, device])

Obtain data of key from data_sample and converse data to device.

mmedit.evaluation.metrics.metrics_utils._assert_ndim(input, name, ndim, shape_hint)[源代码]
mmedit.evaluation.metrics.metrics_utils._assert_masked(pred_alpha, trimap)[源代码]
mmedit.evaluation.metrics.metrics_utils._fetch_data_and_check(data_samples)[源代码]

Fetch and check data from one item of data_batch and predictions.

参数
  • data_batch (dict) – One item of data_batch.

  • predictions (dict) – One item of predictions.

返回

Pred_alpha data of predictions. ori_alpha (Tensor): Ori_alpha data of data_batch. ori_trimap (Tensor): Ori_trimap data of data_batch.

返回类型

pred_alpha (Tensor)

mmedit.evaluation.metrics.metrics_utils.average(results, key)[源代码]

Average of key in results(list[dict]).

参数
  • results (list[dict]) – A list of dict containing the necessary data.

  • key (str) – The key of target data.

返回

The average result.

返回类型

result

mmedit.evaluation.metrics.metrics_utils.img_transform(img, crop_border=0, input_order='HWC', convert_to=None, channel_order='rgb')[源代码]

Image transform.

Ref: https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio

参数
  • img (np.ndarray) – Images with range [0, 255].

  • crop_border (int) – Cropped pixels in each edges of an image. These pixels are not involved in the PSNR calculation. Default: 0.

  • input_order (str) – Whether the input order is ‘HWC’ or ‘CHW’. Default: ‘HWC’.

  • convert_to (str) – Whether to convert the images to other color models. If None, the images are not altered. When computing for ‘Y’, the images are assumed to be in BGR order. Options are ‘Y’ and None. Default: None.

  • channel_order (str) – The channel order of image. Default: ‘rgb’

返回

PSNR result.

返回类型

float

mmedit.evaluation.metrics.metrics_utils.obtain_data(data_sample, key, device='cpu')[源代码]

Obtain data of key from data_sample and converse data to device. :param data_sample: A dict of data sample. :type data_sample: dict :param key: The key of data to obtain. :type key: str :param device: Which device the data will deploy. Default: ‘cpu’. :type device: str

返回

The data of key.

返回类型

result (Tensor | np.ndarray)

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.