MCPcopy Create free account
hub / github.com/ZhengPeng7/BiRefNet / SEWeightModule

Class SEWeightModule

models/modules/attentions.py:7–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5
6
7class SEWeightModule(nn.Module):
8 def __init__(self, channels, reduction=16):
9 super(SEWeightModule, self).__init__()
10 self.avg_pool = nn.AdaptiveAvgPool2d(1)
11 self.fc1 = nn.Conv2d(channels, channels//reduction, kernel_size=1, padding=0)
12 self.relu = nn.ReLU(inplace=True)
13 self.fc2 = nn.Conv2d(channels//reduction, channels, kernel_size=1, padding=0)
14 self.sigmoid = nn.Sigmoid()
15
16 def forward(self, x):
17 out = self.avg_pool(x)
18 out = self.fc1(out)
19 out = self.relu(out)
20 out = self.fc2(out)
21 weight = self.sigmoid(out)
22 return weight
23
24
25class PSA(nn.Module):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected