-
Notifications
You must be signed in to change notification settings - Fork 0
/
evaluation_utils.py
36 lines (25 loc) · 1018 Bytes
/
evaluation_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import numpy as np
def evaluate_3d(sf_pred, sf_gt):
"""
sf_pred: (N, 3)
sf_gt: (N, 3)
"""
l2_norm = np.linalg.norm(sf_gt - sf_pred, axis=-1)
EPE3D = l2_norm.mean()
sf_norm = np.linalg.norm(sf_gt, axis=-1)
relative_err = l2_norm / (sf_norm + 1e-4)
acc3d_strict = (np.logical_or(l2_norm < 0.05, relative_err < 0.05)).astype(np.float).mean()
acc3d_relax = (np.logical_or(l2_norm < 0.1, relative_err < 0.1)).astype(np.float).mean()
outlier = (np.logical_or(l2_norm > 0.3, relative_err > 0.1)).astype(np.float).mean()
return EPE3D, acc3d_strict, acc3d_relax, outlier
def evaluate_2d(flow_pred, flow_gt):
"""
flow_pred: (N, 2)
flow_gt: (N, 2)
"""
epe2d = np.linalg.norm(flow_gt - flow_pred, axis=-1)
epe2d_mean = epe2d.mean()
flow_gt_norm = np.linalg.norm(flow_gt, axis=-1)
relative_err = epe2d / (flow_gt_norm + 1e-5)
acc2d = (np.logical_or(epe2d < 3., relative_err < 0.05)).astype(np.float).mean()
return epe2d_mean, acc2d