(self, features, is_training=True, **kwargs)
| 183 | return locations.to(x) |
| 184 | |
| 185 | def forward(self, features, is_training=True, **kwargs): |
| 186 | output = {} |
| 187 | coord_features = self.compute_coordinates(features) |
| 188 | features = torch.cat([coord_features, features], dim=1) |
| 189 | inst_output = self.inst_branch( |
| 190 | features, is_training=is_training) |
| 191 | output.update(inst_output) |
| 192 | |
| 193 | if is_training: |
| 194 | mask_features = self.mask_branch(features) |
| 195 | pred_kernel = inst_output['pred_kernel'] |
| 196 | N = pred_kernel.shape[1] |
| 197 | B, C, H, W = mask_features.shape |
| 198 | |
| 199 | pred_masks = torch.bmm(pred_kernel, mask_features.view( |
| 200 | B, C, H * W)).view(B, N, H, W) |
| 201 | pred_masks = F.interpolate( |
| 202 | pred_masks, scale_factor=self.scale_factor, |
| 203 | mode='bilinear', align_corners=False) |
| 204 | output.update(dict( |
| 205 | pred_masks=pred_masks)) |
| 206 | |
| 207 | if self.training: |
| 208 | sparse_inst_losses, matched_indices = self.loss( |
| 209 | output, |
| 210 | lane_idx_map=kwargs.get('lane_idx_map'), |
| 211 | input_shape=kwargs.get('input_shape') |
| 212 | ) |
| 213 | for k, v in sparse_inst_losses.items(): |
| 214 | sparse_inst_losses[k] = self.sparse_decoder_weight * v |
| 215 | output.update(sparse_inst_losses) |
| 216 | output['matched_indices'] = matched_indices |
| 217 | return output |
| 218 | |
| 219 | def loss(self, output, lane_idx_map, input_shape): |
| 220 | """ |
nothing calls this directly
no test coverage detected