-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmetrics.py
More file actions
27 lines (22 loc) · 1.15 KB
/
metrics.py
File metadata and controls
27 lines (22 loc) · 1.15 KB
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
# Copyright (c) Meta Platforms, Inc. and affiliates.
import numpy as np
class MADEComputer:
def __init__(self, is_valid_pixel_mask: np.ndarray, log_depth_gt: np.ndarray):
assert is_valid_pixel_mask.ndim == 2 and is_valid_pixel_mask.dtype == bool
assert log_depth_gt.shape == is_valid_pixel_mask.shape
self._H, self._W = is_valid_pixel_mask.shape
self._is_valid_pixel_mask = is_valid_pixel_mask
self._depth_gt = np.exp(log_depth_gt)
def compute_curr_made(self, log_z: np.ndarray, return_scale: bool = False):
# Based on https://github.com/xucao-42/bilateral_normal_integration/blob/
# e819fc11742c1316bcc649d078848096b6d77e85/evaluation_diligent.py#L41-L44.
assert log_z.shape == (self._H, self._W)
depth_map = np.exp(log_z)
scale = np.nanmedian(self._depth_gt / depth_map)
scaled_depth = depth_map * scale
absolute_difference_map = np.abs(scaled_depth - self._depth_gt)
made = np.nanmean(absolute_difference_map)
if return_scale:
return made, absolute_difference_map, scale
else:
return made, absolute_difference_map