(depth, return_mask=False)
| 99 | |
| 100 | |
| 101 | def depth2disparity(depth, return_mask=False): |
| 102 | if isinstance(depth, torch.Tensor): |
| 103 | disparity = torch.zeros_like(depth) |
| 104 | elif isinstance(depth, np.ndarray): |
| 105 | disparity = np.zeros_like(depth) |
| 106 | non_negtive_mask = depth > 0 |
| 107 | disparity[non_negtive_mask] = 1.0 / depth[non_negtive_mask] |
| 108 | if return_mask: |
| 109 | return disparity, non_negtive_mask |
| 110 | else: |
| 111 | return disparity |
| 112 | |
| 113 | |
| 114 | def absolute_error_loss(params, predicted_depth, ground_truth_depth): |