Initialize Gaussians with multilayer representation. The returned tensors have the shape batch_size x dim x num_layers x height x width where dim indicates the dimensionality of the property. Some of the dimensions might be set to 1 for efficiency reasons.
| 62 | |
| 63 | |
| 64 | class MultiLayerInitializer(nn.Module): |
| 65 | """Initialize Gaussians with multilayer representation. |
| 66 | |
| 67 | The returned tensors have the shape |
| 68 | |
| 69 | batch_size x dim x num_layers x height x width |
| 70 | |
| 71 | where dim indicates the dimensionality of the property. |
| 72 | Some of the dimensions might be set to 1 for efficiency reasons. |
| 73 | """ |
| 74 | |
| 75 | def __init__( |
| 76 | self, |
| 77 | num_layers: int, |
| 78 | stride: int, |
| 79 | base_depth: float, |
| 80 | scale_factor: float, |
| 81 | disparity_factor: float, |
| 82 | color_option: ColorInitOption = "first_layer", |
| 83 | first_layer_depth_option: DepthInitOption = "surface_min", |
| 84 | rest_layer_depth_option: DepthInitOption = "surface_min", |
| 85 | normalize_depth: bool = True, |
| 86 | feature_input_stop_grad: bool = True, |
| 87 | ) -> None: |
| 88 | """Initialize MultilayerInitializer. |
| 89 | |
| 90 | Args: |
| 91 | stride: The downsample rate of output feature map. |
| 92 | base_depth: The depth of the first layer (after the foreground |
| 93 | layer if use_depth=True). |
| 94 | scale_factor: Multiply scale of Gaussians by this factor. |
| 95 | disparity_factor: Factor to convert inverse depth to disparity. |
| 96 | num_layers: How many layers of Gaussians to predict. |
| 97 | color_option: Which color option to initialize the multi-layer gaussians. |
| 98 | first_layer_depth_option: Which depth option to initialize the first layer of gaussians. |
| 99 | rest_layer_depth_option: Which depth option to initialize the rest layers of gaussians. |
| 100 | normalize_depth: # Whether to normalize depth to [DepthTransformParam.depth_min, |
| 101 | DepthTransformParam.depth_max). |
| 102 | feature_input_stop_grad: Whether to not propagate gradients through feature inputs. |
| 103 | """ |
| 104 | super().__init__() |
| 105 | self.num_layers = num_layers |
| 106 | self.stride = stride |
| 107 | self.base_depth = base_depth |
| 108 | self.scale_factor = scale_factor |
| 109 | self.disparity_factor = disparity_factor |
| 110 | self.color_option = color_option |
| 111 | self.first_layer_depth_option = first_layer_depth_option |
| 112 | self.rest_layer_depth_option = rest_layer_depth_option |
| 113 | self.normalize_depth = normalize_depth |
| 114 | self.feature_input_stop_grad = feature_input_stop_grad |
| 115 | |
| 116 | def prepare_feature_input(self, image: torch.Tensor, depth: torch.Tensor) -> torch.Tensor: |
| 117 | """Prepare the feature input to the Guassian predictor.""" |
| 118 | if self.feature_input_stop_grad: |
| 119 | image = image.detach() |
| 120 | depth = depth.detach() |
| 121 |
no outgoing calls
no test coverage detected