GRADE / src /Baselines /radarcam-depth /utils /eval_utils.py
Bin-0815's picture
Release all GRADE models, checkpoints, and reviewed evaluation code (part 2)
f348660 verified
Raw History Blame Contribute Delete
2.37 kB
"""Metric utilities used by the RadarCam-Depth evaluation backend."""
import numpy as np
def root_mean_sq_err(src, tgt):
'''
Root mean squared error
Arg(s):
src : numpy[float32]
source array
tgt : numpy[float32]
target array
Returns:
float : root mean squared error
'''
return np.sqrt(np.mean((tgt - src) ** 2))
def mean_abs_err(src, tgt):
'''
Mean absolute error
Arg(s):
src : numpy[float32]
source array
tgt : numpy[float32]
target array
Returns:
float : mean absolute error
'''
return np.mean(np.abs(tgt - src))
def inv_root_mean_sq_err(src, tgt):
'''
Inverse root mean squared error
Arg(s):
src : numpy[float32]
source array
tgt : numpy[float32]
target array
Returns:
float : inverse root mean squared error
'''
return np.sqrt(np.mean(((1.0 / tgt) - (1.0 / src)) ** 2))
def inv_mean_abs_err(src, tgt):
'''
Inverse mean absolute error
Arg(s):
src : numpy[float32]
source array
tgt : numpy[float32]
target array
Returns:
float : inverse mean absolute error
'''
return np.mean(np.abs((1.0 / tgt) - (1.0 / src)))
def mean_abs_rel_err(src, tgt):
'''
Mean absolute relative error (normalize absolute error)
Arg(s):
src : numpy[float32]
source array
tgt : numpy[float32]
target array
Returns:
float : mean absolute relative error between source and target
'''
return np.mean(np.abs(src - tgt) / tgt)
def mean_sq_rel_err(src, tgt):
'''
Mean squared relative error (normalize squared error)
Arg(s):
src : numpy[float32]
source array
tgt : numpy[float32]
target array
Returns:
float : mean squared relative error between source and target
'''
return np.mean(((src - tgt) ** 2) / tgt)
def thr_acc(src, tgt, thr=1.25):
'''
Threshold accuracy
Arg(s):
src : numpy[float32]
source array
tgt : numpy[float32]
target array
thr : float
threshold
Returns:
float : threshold accuracy
'''
return np.mean(np.maximum((tgt / src), (src / tgt)) < thr)