MCPcopy Create free account
hub / github.com/RolandGao/RegSeg / SFNetDecoder

Class SFNetDecoder

competitor_blocks.py:180–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178 x=self.classifier(x)
179 return x
180class SFNetDecoder(nn.Module):
181 def __init__(self, num_classes, channels, fpn_dim=64, fpn_dsn=False):
182 super().__init__()
183 channels8,channels16=channels["8"],channels["16"]
184 self.head16 = PSPModule(channels16,fpn_dim)
185 self.head8=ConvBnAct(channels8,fpn_dim)
186 self.fpn_dsn = fpn_dsn
187 self.fpn_align=AlignedModule(inplane=fpn_dim, outplane=fpn_dim//2)
188 self.conv=ConvBnAct(fpn_dim, fpn_dim, 3, 1, 1)
189 self.conv_last = nn.Sequential(
190 ConvBnAct(2*fpn_dim,fpn_dim,3,1,1),
191 nn.Conv2d(fpn_dim, num_classes, kernel_size=1)
192 )
193
194 def forward(self, x):
195 x8,x16= x["8"], x["16"]
196 x16=self.head16(x16)
197 x8=self.head8(x8)
198 x16_up = self.fpn_align([x8, x16])
199 x8 = x8 + x16_up
200 x8=self.conv(x8)
201 x16_up=F.interpolate(x16, x8.shape[-2:], mode="bilinear", align_corners=True)
202 x8=torch.cat([x8,x16_up],dim=1)
203 x = self.conv_last(x8)
204 return x
205
206class FaPNDecoder(nn.Module):
207 # FaPN paper

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected