| 159 | |
| 160 | |
| 161 | class DepthNet(nn.Module): |
| 162 | def __init__(self, in_channels, mid_channels, context_channels, |
| 163 | depth_channels): |
| 164 | super(DepthNet, self).__init__() |
| 165 | self.reduce_conv = nn.Sequential( |
| 166 | nn.Conv2d(in_channels, |
| 167 | mid_channels, |
| 168 | kernel_size=3, |
| 169 | stride=1, |
| 170 | padding=1), |
| 171 | nn.BatchNorm2d(mid_channels), |
| 172 | nn.ReLU(inplace=True), |
| 173 | ) |
| 174 | self.context_conv = nn.Conv2d(mid_channels, |
| 175 | context_channels, |
| 176 | kernel_size=1, |
| 177 | stride=1, |
| 178 | padding=0) |
| 179 | self.bn = nn.BatchNorm1d(22) |
| 180 | self.depth_mlp = Mlp(22, mid_channels, mid_channels) |
| 181 | self.depth_se = SELayer(mid_channels) # NOTE: add camera-aware |
| 182 | self.context_mlp = Mlp(22, mid_channels, mid_channels) |
| 183 | self.context_se = SELayer(mid_channels) # NOTE: add camera-aware |
| 184 | self.depth_conv = nn.Sequential( |
| 185 | BasicBlock(mid_channels, mid_channels), |
| 186 | BasicBlock(mid_channels, mid_channels), |
| 187 | BasicBlock(mid_channels, mid_channels), |
| 188 | ASPP(mid_channels, mid_channels), |
| 189 | build_conv_layer(cfg=dict( |
| 190 | type='DCN', |
| 191 | in_channels=mid_channels, |
| 192 | out_channels=mid_channels, |
| 193 | kernel_size=3, |
| 194 | padding=1, |
| 195 | groups=4, |
| 196 | im2col_step=128, |
| 197 | )), |
| 198 | nn.Conv2d(mid_channels, |
| 199 | depth_channels, |
| 200 | kernel_size=1, |
| 201 | stride=1, |
| 202 | padding=0), |
| 203 | ) |
| 204 | self.fp16_enabled = False |
| 205 | |
| 206 | def forward(self, x, mats_dict): # mats_dict B x T x N |
| 207 | intrins = mats_dict['intrin_mats'][:, -1:, ..., :3, :3] |
| 208 | batch_size = intrins.shape[0] |
| 209 | num_cams = intrins.shape[2] |
| 210 | ida = mats_dict['ida_mats'][:, -1:, ...] |
| 211 | sensor2ego = mats_dict['sensor2ego_mats'][:, -1:, ..., :3, :] |
| 212 | mlp_input = torch.cat( |
| 213 | [ |
| 214 | torch.stack( |
| 215 | [ |
| 216 | intrins[:, 0:1, ..., 0, 0], |
| 217 | intrins[:, 0:1, ..., 1, 1], |
| 218 | intrins[:, 0:1, ..., 0, 2], |
no outgoing calls
no test coverage detected