(self, features)
| 349 | self.gdt_convs_attn_2 = nn.Sequential(nn.Conv2d(_N, 1, 1, 1, 0)) |
| 350 | |
| 351 | def forward(self, features): |
| 352 | if self.training and self.config.out_ref: |
| 353 | outs_gdt_pred = [] |
| 354 | outs_gdt_label = [] |
| 355 | x, x1, x2, x3, x4, gdt_gt = features |
| 356 | else: |
| 357 | x, x1, x2, x3, x4 = features |
| 358 | outs = [] |
| 359 | |
| 360 | if self.config.dec_ipt: |
| 361 | patches_batch = ( |
| 362 | image2patches( |
| 363 | x, |
| 364 | patch_ref=x4, |
| 365 | transformation="b c (hg h) (wg w) -> b (c hg wg) h w", |
| 366 | ) |
| 367 | if self.split |
| 368 | else x |
| 369 | ) |
| 370 | x4 = torch.cat( |
| 371 | ( |
| 372 | x4, |
| 373 | self.ipt_blk5( |
| 374 | F.interpolate( |
| 375 | patches_batch, |
| 376 | size=x4.shape[2:], |
| 377 | mode="bilinear", |
| 378 | align_corners=True, |
| 379 | ) |
| 380 | ), |
| 381 | ), |
| 382 | 1, |
| 383 | ) |
| 384 | p4 = self.decoder_block4(x4) |
| 385 | m4 = ( |
| 386 | self.conv_ms_spvn_4(p4) |
| 387 | if self.config.ms_supervision and self.training |
| 388 | else None |
| 389 | ) |
| 390 | if self.config.out_ref: |
| 391 | p4_gdt = self.gdt_convs_4(p4) |
| 392 | if self.training: |
| 393 | # >> GT: |
| 394 | m4_dia = m4 |
| 395 | gdt_label_main_4 = gdt_gt * F.interpolate( |
| 396 | m4_dia, size=gdt_gt.shape[2:], mode="bilinear", align_corners=True |
| 397 | ) |
| 398 | outs_gdt_label.append(gdt_label_main_4) |
| 399 | # >> Pred: |
| 400 | gdt_pred_4 = self.gdt_convs_pred_4(p4_gdt) |
| 401 | outs_gdt_pred.append(gdt_pred_4) |
| 402 | gdt_attn_4 = self.gdt_convs_attn_4(p4_gdt).sigmoid() |
| 403 | # >> Finally: |
| 404 | p4 = p4 * gdt_attn_4 |
| 405 | _p4 = F.interpolate(p4, size=x3.shape[2:], mode="bilinear", align_corners=True) |
| 406 | _p3 = _p4 + self.lateral_block4(x3) |
| 407 | |
| 408 | if self.config.dec_ipt: |
nothing calls this directly
no test coverage detected