-
Notifications
You must be signed in to change notification settings - Fork 23
/
evaluation_utils.py
50 lines (37 loc) · 1.41 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""
Evaluation metrics
Borrowed from HPLFlowNet
Date: May 2020
@inproceedings{HPLFlowNet,
title={HPLFlowNet: Hierarchical Permutohedral Lattice FlowNet for
Scene Flow Estimation on Large-scale Point Clouds},
author={Gu, Xiuye and Wang, Yijie and Wu, Chongruo and Lee, Yong Jae and Wang, Panqu},
booktitle={Computer Vision and Pattern Recognition (CVPR), 2019 IEEE International Conference on},
year={2019}
}
"""
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