Create multiple surface layers.
(
depth: torch.Tensor,
depth_pooling_mode: str,
)
| 157 | ) |
| 158 | |
| 159 | def _create_surface_layer( |
| 160 | depth: torch.Tensor, |
| 161 | depth_pooling_mode: str, |
| 162 | ) -> torch.Tensor: |
| 163 | """Create multiple surface layers.""" |
| 164 | disparity = 1.0 / depth |
| 165 | if depth_pooling_mode == "min": |
| 166 | disparity = torch.max_pool2d(disparity, self.stride, self.stride) |
| 167 | elif depth_pooling_mode == "max": |
| 168 | disparity = -torch.max_pool2d(-disparity, self.stride, self.stride) |
| 169 | else: |
| 170 | raise ValueError(f"Invalid depth pooling mode {depth_pooling_mode}.") |
| 171 | |
| 172 | return disparity[:, :, None, :, :] |
| 173 | |
| 174 | # Input disparity dimensions: |
| 175 | # (batch_size, num_channels in (1, 2), height, width) |
nothing calls this directly
no outgoing calls
no test coverage detected