Shortcuts

EndPointError

class mmeval.metrics.EndPointError(**kwargs)[source]

EndPointError evaluation metric.

EndPointError is a widely used evaluation metric for optical flow estimation.

This metric supports 3 kinds of inputs, i.e. numpy.ndarray and torch.Tensor, oneflow.Tensor, and the implementation for the calculation depends on the inputs type.

Parameters

**kwargs – Keyword arguments passed to BaseMetric.

Examples

>>> from mmeval import EndPointError
>>> epe = EndPointError()

Use NumPy implementation:

>>> import numpy as np
>>> predictions = np.array(
...     [[[10., 5.], [0.1, 3.]],
...     [[3., 15.2], [2.4, 4.5]]])
>>> labels = np.array(
...     [[[10.1, 4.8], [10, 3.]],
...     [[6., 10.2], [2.0, 4.1]]])
>>> valid_masks = np.array([[1., 1.], [1., 0.]])
>>> epe(predictions, labels, valid_masks)
{'EPE': 5.318186230865093}

Use PyTorch implementation:

>>> import torch
>>> predictions = torch.Tensor(
...     [[[10., 5.], [0.1, 3.]],
...     [[3., 15.2], [2.4, 4.5]]])
>>> labels = torch.Tensor(
...     [[[10.1, 4.8], [10, 3.]],
...     [[6., 10.2], [2.0, 4.1]]])
>>> valid_masks = torch.Tensor([[1., 1.], [1., 0.]])
>>> epe(predictions, labels, valid_masks)
{'EPE': 5.3181863}

Accumulate batch:

>>> for i in range(10):
...     predictions = torch.randn(10, 10, 2)
...     labels = torch.randn(10, 10, 2)
...     epe.add(predictions, labels)
>>> epe.compute()  
add(predictions: Sequence, labels: Sequence, valid_masks: Optional[Sequence] = None)None[source]

Process one batch of predictions and labels.

Parameters
  • predictions (Sequence) – Predicted sequence of flow map with shape (H, W, 2).

  • labels (Sequence) – The ground truth sequence of flow map with shape (H, W, 2).

  • valid_masks (Sequence) – The Sequence of valid mask for labels with shape (H, W). If it is None, this function will automatically generate a map filled with 1. Defaults to None.

compute_metric(results: List[Tuple[numpy.ndarray, int]])dict[source]

Compute the EndPointError metric.

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

Parameters

results (List[np.ndarray]) – This list has already been synced across all ranks. This is a list of np.ndarray, which is the end point error map between the prediction and the label.

Returns

The computed metric, with following key:

  • EPE, the mean end point error of all pairs.

Return type

Dict

end_point_error_map[source]

Calculate end point error map.

Parameters
  • prediction (np.ndarray) – Prediction with shape (H, W, 2).

  • label (np.ndarray) – Ground truth with shape (H, W, 2).

  • valid_mask (np.ndarray, optional) – Valid mask with shape (H, W).

Returns

The mean of end point error and the numbers of valid labels.

Return type

Tuple

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.