Optical flow#
- kornia.metrics.aepe(input, target, reduction='mean')[source]#
Compute the average endpoint error (AEPE) between two flow maps.
epe = aepe(input, target)takes two channel-last flows(*, 2), such as(B, H, W, 2), and returns the mean Euclidean distance between their vectors, in the units of the flow. For anh x wflow the AEPE is:\[\text{AEPE}=\frac{1}{hw}\sum_{i=1, j=1}^{h, w}\sqrt{(I_{i,j,1}-T_{i,j,1})^{2}+(I_{i,j,2}-T_{i,j,2})^{2}}\]- Convention:
A channel-first
(B, 2, H, W)flow must be permuted to(B, H, W, 2)first: it raises unless \(W = 2\), where it is read wrongly. Losses and metrics ports RAFT’s endpoint error.The distance is symmetric in
inputandtargetand not normalized by the image size.reduction='mean'averages it over every position of every sample at once and'sum'adds it up, both into a 0-d tensor;'none'returns the(*)map. There is no valid mask: mask sparse ground truth on the'none'map. An unknownreductionraisesNotImplementedError.aepe()andaverage_endpoint_error()are the same function.Float16 and bfloat16 inputs are computed in float32 and the result is returned in their promoted dtype.
- Parameters:
- Return type:
- Returns:
a 0-d tensor, or the map of shape
(*)forreduction='none'.
See also
AEPE: the module form.
Examples
>>> ones = torch.ones(4, 4, 2) >>> aepe(ones, 1.2 * ones) tensor(0.2828)
- kornia.metrics.average_endpoint_error(input, target, reduction='mean')[source]#
Compute the average endpoint error (AEPE) between two flow maps.
epe = aepe(input, target)takes two channel-last flows(*, 2), such as(B, H, W, 2), and returns the mean Euclidean distance between their vectors, in the units of the flow. For anh x wflow the AEPE is:\[\text{AEPE}=\frac{1}{hw}\sum_{i=1, j=1}^{h, w}\sqrt{(I_{i,j,1}-T_{i,j,1})^{2}+(I_{i,j,2}-T_{i,j,2})^{2}}\]- Convention:
A channel-first
(B, 2, H, W)flow must be permuted to(B, H, W, 2)first: it raises unless \(W = 2\), where it is read wrongly. Losses and metrics ports RAFT’s endpoint error.The distance is symmetric in
inputandtargetand not normalized by the image size.reduction='mean'averages it over every position of every sample at once and'sum'adds it up, both into a 0-d tensor;'none'returns the(*)map. There is no valid mask: mask sparse ground truth on the'none'map. An unknownreductionraisesNotImplementedError.aepe()andaverage_endpoint_error()are the same function.Float16 and bfloat16 inputs are computed in float32 and the result is returned in their promoted dtype.
- Parameters:
- Return type:
- Returns:
a 0-d tensor, or the map of shape
(*)forreduction='none'.
See also
AEPE: the module form.
Examples
>>> ones = torch.ones(4, 4, 2) >>> aepe(ones, 1.2 * ones) tensor(0.2828)
- class kornia.metrics.AEPE(reduction='mean')[source]#
Compute the average endpoint error (AEPE) between two flow maps (module form).
criterion = AEPE(reduction)storesreduction, andepe = criterion(input, target)isaepe()on two(*, 2)flows.- Convention:
See the Convention block of
aepe().
- Parameters:
reduction (
str, optional) –'mean'(default),'sum'or'none', as inaepe(). Default:"mean"
- Shape:
input:
(*, 2).target:
(*, 2).output:
()for'mean'and'sum',(*)for'none'.
See also
aepe(): the one-call form.
Examples
>>> input1 = torch.rand(1, 4, 5, 2) >>> input2 = torch.rand(1, 4, 5, 2) >>> epe = AEPE(reduction="mean") >>> epe = epe(input1, input2)