| 271 | return x |
| 272 | |
| 273 | class Exp2_Decoder26(nn.Module): |
| 274 | def __init__(self, num_classes, channels): |
| 275 | super().__init__() |
| 276 | channels4,channels8,channels16=channels["4"],channels["8"],channels["16"] |
| 277 | self.head16=ConvBnAct(channels16, 128, 1) |
| 278 | self.head8=ConvBnAct(channels8, 128, 1) |
| 279 | self.head4=ConvBnAct(channels4, 8, 1) |
| 280 | self.conv8=ConvBnAct(128,64,3,1,1) |
| 281 | self.conv4=ConvBnAct(64+8,64,3,1,1) |
| 282 | self.classifier=nn.Conv2d(64, num_classes, 1) |
| 283 | |
| 284 | def forward(self, x): |
| 285 | x4, x8, x16=x["4"], x["8"],x["16"] |
| 286 | x16=self.head16(x16) |
| 287 | x8=self.head8(x8) |
| 288 | x4=self.head4(x4) |
| 289 | x16 = F.interpolate(x16, size=x8.shape[-2:], mode='bilinear', align_corners=False) |
| 290 | x8= x8 + x16 |
| 291 | x8=self.conv8(x8) |
| 292 | x8 = F.interpolate(x8, size=x4.shape[-2:], mode='bilinear', align_corners=False) |
| 293 | x4=torch.cat((x8,x4),dim=1) |
| 294 | x4=self.conv4(x4) |
| 295 | x4=self.classifier(x4) |
| 296 | return x4 |
| 297 | |
| 298 | class Exp2_Decoder29(nn.Module): |
| 299 | def __init__(self, num_classes, channels): |