Shortcuts

SumAbsoluteDifferences

class mmeval.metrics.SumAbsoluteDifferences(norm_const: int = 1000, **kwargs)[源代码]

Sum of Absolute Differences metric for image.

This metric computes per-pixel absolute difference and sum across all pixels. i.e. sum(abs(a-b)) / norm_const

参数
  • norm_const (int) – Divide the result to reduce its magnitude. Default to 1000.

  • **kwargs – Keyword parameters passed to BaseMetric.

注解

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

实际案例

>>> from mmeval import SumAbsoluteDifferences as SAD
>>> import numpy as np
>>>
>>> sad = SAD()
>>> prediction = np.zeros((32, 32), dtype=np.uint8)
>>> groundtruth = np.ones((32, 32), dtype=np.uint8) * 255
>>> sad(prediction, groundtruth)  
{'sad': ...}
add(predictions: Sequence[numpy.ndarray], groundtruths: Sequence[numpy.ndarray])None[源代码]

Add SumAbsoluteDifferences score of batch to self._results

参数
  • predictions (Sequence[np.ndarray]) – Sequence of predicted image.

  • groundtruths (Sequence[np.ndarray]) – Sequence of groundtruth image.

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

Compute the SumAbsoluteDifferences metric.

参数

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

返回

The computed SumAbsoluteDifferences 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.