MCPcopy Create free account
hub / github.com/ChunmingHe/WS-SAM / Decoder4_noEdge

Class Decoder4_noEdge

lib/Modules.py:841–863  ·  view source on GitHub ↗

Input: feature maps from the current stage, the segment map from the previous stage Output: the segmentation map from the current stage

Source from the content-addressed store, hash-verified

839 return f1,f2,f3,f4
840
841class Decoder4_noEdge(nn.Module):
842 '''
843 Input: feature maps from the current stage, the segment map from the previous stage
844 Output: the segmentation map from the current stage
845 '''
846 def __init__(self, in_channels):
847 super(Decoder4_noEdge, self).__init__()
848 self.rcab_a = RCAB(in_channels)
849 self.rcab_b = RCAB(in_channels)
850
851 self.conv3x3 = BasicConv2d(in_channels * 2, in_channels, kernel_size=3, padding=1)
852 self.out_s = nn.Conv2d(in_channels, 1, kernel_size=3, padding=1)
853
854 def forward(self, f4, prior_cam):
855 prior_cam = F.interpolate(prior_cam, size=f4.size()[2:], mode='bilinear', align_corners=True) # 2,1,12,12->2,1,48,48
856 r_prior_cam = 1 - torch.sigmoid(prior_cam)
857 prior_cam = torch.sigmoid(prior_cam)
858 f4_a = self.rcab_a(f4 * r_prior_cam.expand(-1, f4.size()[1], -1, -1) + f4)
859 f4_b = self.rcab_b(f4 * prior_cam.expand(-1, f4.size()[1], -1, -1) + f4)
860 f4_s = self.conv3x3(torch.cat([f4_a, f4_b], 1))
861 p4_s = self.out_s(f4_s)
862
863 return p4_s
864
865
866class Decoder_noSpade(nn.Module):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected