Dense Prediction Transformer for Gaussian. Reuse monodepth decoded features for processing.
| 123 | |
| 124 | |
| 125 | class GaussianDensePredictionTransformer(nn.Module): |
| 126 | """Dense Prediction Transformer for Gaussian. |
| 127 | |
| 128 | Reuse monodepth decoded features for processing. |
| 129 | """ |
| 130 | |
| 131 | norm_type: NormLayerName |
| 132 | |
| 133 | def __init__( |
| 134 | self, |
| 135 | decoder: BaseDecoder, |
| 136 | dim_in: int, |
| 137 | dim_out: int, |
| 138 | stride_out: int, |
| 139 | image_encoder_params: GaussianDecoderParams, |
| 140 | image_encoder_type: DPTImageEncoderType = "skip_conv", |
| 141 | norm_type: NormLayerName = "group_norm", |
| 142 | norm_num_groups: int = 8, |
| 143 | use_depth_input: bool = True, |
| 144 | grad_checkpointing: bool = False, |
| 145 | ): |
| 146 | """Initialize Dense Prediction Transformer for Gaussian. |
| 147 | |
| 148 | Args: |
| 149 | decoder: Decoder to decode features. |
| 150 | monodepth_decoder: Optional monodepth decoder to fuse monodepth decoded features. |
| 151 | dim_in: Input dimension. |
| 152 | dim_out: Final output dimension. |
| 153 | stride_out: Stride of output feature map. |
| 154 | image_encoder_params: The backbone parameters to configurate the image encoder. |
| 155 | image_encoder_type: Type of image encoder to use. |
| 156 | encoder: Encoder to generate features using monodepth model. |
| 157 | norm_type: Type of norm layers. |
| 158 | norm_num_groups: Num groups for norm layers. |
| 159 | use_depth_input: Whether to use depth input. |
| 160 | grad_checkpointing: Whether to use gradient checkpointing. |
| 161 | """ |
| 162 | super().__init__() |
| 163 | |
| 164 | self.decoder = decoder |
| 165 | self.dim_in = dim_in |
| 166 | self.dim_out = dim_out |
| 167 | self.stride_out = stride_out |
| 168 | self.norm_type = norm_type |
| 169 | self.norm_num_groups = norm_num_groups |
| 170 | self.use_depth_input = use_depth_input |
| 171 | self.grad_checkpointing = grad_checkpointing |
| 172 | self.image_encoder_type = image_encoder_type |
| 173 | |
| 174 | # Adopt an image encoder to lift dimension to monodepth feature and |
| 175 | # resize to be the same resolution as the decoder output. |
| 176 | dim_in = self.dim_in if use_depth_input else self.dim_in - 1 |
| 177 | image_encoder_params.dim_in = dim_in |
| 178 | image_encoder_params.dim_out = decoder.dim_out |
| 179 | self.image_encoder = self._create_image_encoder(image_encoder_params, stride_out) |
| 180 | |
| 181 | self.fusion = FeatureFusionBlock2d(decoder.dim_out) |
| 182 |
no outgoing calls
no test coverage detected