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

Class Decoder4_noRCAB

lib/Modules.py:952–972  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

950 return prior_cam, p4_s_out, p3_s_out, p2_s_out, p1_s_out
951
952class Decoder4_noRCAB(nn.Module):
953 def __init__(self, in_channels):
954 super(Decoder4_noRCAB, self).__init__()
955 self.crb = BasicConv2d(in_channels, in_channels, kernel_size=3, padding=1)
956 self.out_e = nn.Conv2d(in_channels, 1, kernel_size=3, padding=1)
957
958 self.conv3x3 = BasicConv2d(in_channels * 2, in_channels, kernel_size=3, padding=1)
959 self.out_s = nn.Conv2d(in_channels, 1, kernel_size=3, padding=1)
960
961 def forward(self, f4, prior_cam):
962 prior_cam = F.interpolate(prior_cam, size=f4.size()[2:], mode='bilinear', align_corners=True) # 2,1,12,12->2,1,48,48
963 r_prior_cam = 1 - torch.sigmoid(prior_cam)
964 prior_cam = torch.sigmoid(prior_cam)
965 f4_a = f4 * r_prior_cam.expand(-1, f4.size()[1], -1, -1) + f4
966 f4_b = f4 * prior_cam.expand(-1, f4.size()[1], -1, -1) + f4
967 f4_s = self.conv3x3(torch.cat([f4_a, f4_b], 1))
968 p4_s = self.out_s(f4_s)
969 f4_e = self.crb(f4)
970 p4_e = self.out_e(f4_e)
971
972 return f4_s, f4_e, p4_s, p4_e
973
974class Decoder_noRCAB(nn.Module):
975 def __init__(self, in_channels):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected