Shortcuts

MeanAbsoluteError

class mmeval.metrics.MeanAbsoluteError(**kwargs)[源代码]

Mean Absolute Error metric for image.

Formula: mean(abs(a-b)).

参数

**kwargs – Keyword parameters passed to BaseMetric.

实际案例

>>> from mmeval import MeanAbsoluteError as MAE
>>> import numpy as np
>>>
>>> mae = MAE()
>>> gts = np.random.randint(0, 255, size=(3, 32, 32))
>>> preds = np.random.randint(0, 255, size=(3, 32, 32))
>>> mae(preds, gts)  
{'mae': ...}

Calculate MeanAbsoluteError between 2 images with mask:

>>> img1 = np.ones((32, 32, 3))
>>> img2 = np.ones((32, 32, 3)) * 2
>>> mask = np.ones((32, 32, 3)) * 2
>>> mask[:16] *= 0
>>> MAE.compute_mae(img1, img2, mask)
0.003921568627
add(predictions: Sequence[numpy.ndarray], groundtruths: Sequence[numpy.ndarray], masks: Optional[Sequence[numpy.ndarray]] = None)None[源代码]

Add MeanAbsoluteError score of batch to self._results

参数
  • predictions (Sequence[np.ndarray]) – Predictions of the model.

  • groundtruths (Sequence[np.ndarray]) – The ground truth images.

  • masks (Sequence[np.ndarray], optional) – Mask images. Defaults to None.

static compute_mae(prediction: numpy.ndarray, groundtruth: numpy.ndarray, mask: Optional[numpy.ndarray] = None)numpy.float32[源代码]

Calculate MeanAbsoluteError (Mean Absolute Error).

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

  • groundtruth (np.ndarray) – Images with range [0, 255].

  • mask (np.ndarray, optional) – Mask of evaluation.

返回

MeanAbsoluteError result.

返回类型

np.float32

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

Compute the MeanAbsoluteError metric.

This method would be invoked in BaseMetric.compute after distributed synchronization.

参数

results (List[np.float32]) – A list that consisting the MeanAbsoluteError score. This list has already been synced across all ranks.

返回

The computed MeanAbsoluteError metric.

返回类型

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.