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

Class Spade

lib/Modules.py:735–754  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

733
734
735class Spade(nn.Module):
736 def __init__(self, hidden_channels, out_channels):
737 super(Spade, self).__init__()
738 self.param_free_norm = nn.BatchNorm2d(out_channels, affine=False)
739 self.mlp_shared = nn.Sequential(
740 nn.Conv2d(hidden_channels, hidden_channels, kernel_size=3, padding=1),
741 nn.ReLU(True)
742 )
743 self.mlp_gamma = nn.Conv2d(hidden_channels, out_channels, kernel_size=3, padding=1)
744 self.mlp_beta = nn.Conv2d(hidden_channels, out_channels, kernel_size=3, padding=1)
745
746 def forward(self, x, edge):
747 normalized = self.param_free_norm(x)
748
749 edge = F.interpolate(edge, size=x.size()[2:], mode='nearest')
750 actv = self.mlp_shared(edge)
751 gamma = self.mlp_gamma(actv)
752 beta = self.mlp_beta(actv)
753 out = normalized * (1 + gamma) + beta
754 return out
755
756
757class Decoder(nn.Module):

Callers 2

__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected