Shortcuts

SumAbsoluteDifferences

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

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

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

  • **kwargs – Keyword parameters passed to BaseMetric.

Note

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

Examples

>>> 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[source]

Add SumAbsoluteDifferences score of batch to self._results

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

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

compute_metric(results: List)Dict[str, float][source]

Compute the SumAbsoluteDifferences metric.

Parameters

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

Returns

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

Return type

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.