-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmetrics_np.py
37 lines (27 loc) · 1.1 KB
/
metrics_np.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
import numpy as np
def accuracy_under_treshold(truth_img, predicted_img, treshold=1.25):
n_pixels = np.prod(truth_img.shape)
delta = np.maximum(predicted_img / truth_img, truth_img / predicted_img)
lower = delta < treshold
ratio = np.sum(lower.astype(np.float32)) / n_pixels
return ratio
def mean_relative_error(truth_img, predicted_img):
n_pixels = np.prod(truth_img.shape)
rel = np.abs(predicted_img - truth_img) / truth_img
rel = np.sum(rel) / n_pixels
return rel
def root_mean_squared_log_error(truth_img, predicted_img):
n_pixels = np.prod(truth_img.shape)
rms = (np.log10(predicted_img) - np.log10(truth_img)) ** 2
rms = np.sqrt(np.sum(rms) / n_pixels)
return rms
def root_mean_squared_error(truth_img, predicted_img):
n_pixels = np.prod(truth_img.shape)
rms = (predicted_img - truth_img) ** 2
rms = np.sqrt(np.sum(rms) / n_pixels)
return rms
def log10_error(truth_img, predicted_img):
n_pixels = np.prod(truth_img.shape)
lg10 = np.abs(np.log10(predicted_img) - np.log10(truth_img))
lg10 = np.sum(lg10) / n_pixels
return lg10