Shortcuts

GradientError

class mmeval.metrics.GradientError(sigma: float = 1.4, norm_const: int = 1000, **kwargs)[源代码]

Gradient error for evaluating alpha matte prediction.

参数
  • sigma (float) – Standard deviation of the gaussian kernel. Defaults to 1.4 .

  • norm_const (int) – Divide the result to reduce its magnitude. Defaults to 1000.

  • **kwargs – Keyword parameters passed to BaseMetric.

注解

The current implementation assumes the image / alpha / trimap a numpy array with pixel values ranging from 0 to 255.

The pred_alpha should be masked by trimap before passing into this metric.

The trimap is the most commonly used prior knowledge. As the name implies, trimap is a ternary graph and each pixel takes one of {0, 128, 255}, representing the foreground, the unknown and the background respectively.

实际案例

>>> from mmeval import GradientError
>>> import numpy as np
>>>
>>> gradient_error = GradientError()
>>> np.random.seed(0)
>>> pred_alpha = np.random.randn(32, 32).astype('uint8')
>>> gt_alpha = np.ones((32, 32), dtype=np.uint8) * 255
>>> trimap = np.zeros((32, 32), dtype=np.uint8)
>>> trimap[:16, :16] = 128
>>> trimap[16:, 16:] = 255
>>> gradient_error(pred_alpha, gt_alpha, trimap)  
{'gradient_error': ...}
add(pred_alphas: Sequence[numpy.ndarray], gt_alphas: Sequence[numpy.ndarray], trimaps: Sequence[numpy.ndarray])None[源代码]

Add GradientError score of batch to self._results

参数
  • pred_alphas (Sequence[np.ndarray]) – Predict the probability that pixels belong to the foreground.

  • gt_alphas (Sequence[np.ndarray]) – Probability that the actual pixel belongs to the foreground.

  • trimaps (Sequence[np.ndarray]) – Broadly speaking, the trimap consists of foreground and unknown region.

compute_metric(results: List)Dict[str, float][源代码]

Compute the GradientError metric.

参数

results (List) – A list that consisting the GradientError score. This list has already been synced across all ranks.

返回

The computed GradientError metric. The keys are the names of the metrics, and the values are corresponding results.

返回类型

Dict[str, float]

Read the Docs v: latest
Versions
latest
stable
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.