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

Method __init__

models/modules/decoder_blocks.py:37–55  ·  view source on GitHub ↗
(self, in_channels=64, out_channels=None, inter_channels=64)

Source from the content-addressed store, hash-verified

35
36class ResBlk(nn.Module):
37 def __init__(self, in_channels=64, out_channels=None, inter_channels=64):
38 super(ResBlk, self).__init__()
39 if out_channels is None:
40 out_channels = in_channels
41 inter_channels = in_channels // 4 if config.dec_channels_inter == 'adap' else 64
42
43 self.conv_in = nn.Conv2d(in_channels, inter_channels, 3, 1, padding=1)
44 self.bn_in = nn.BatchNorm2d(inter_channels) if config.batch_size > 1 else nn.Identity()
45 self.relu_in = nn.ReLU(inplace=True)
46
47 if config.dec_att == 'ASPP':
48 self.dec_att = ASPP(in_channels=inter_channels)
49 elif config.dec_att == 'ASPPDeformable':
50 self.dec_att = ASPPDeformable(in_channels=inter_channels)
51
52 self.conv_out = nn.Conv2d(inter_channels, out_channels, 3, 1, padding=1)
53 self.bn_out = nn.BatchNorm2d(out_channels) if config.batch_size > 1 else nn.Identity()
54
55 self.conv_resi = nn.Conv2d(in_channels, out_channels, 1, 1, 0)
56
57 def forward(self, x):
58 _x = self.conv_resi(x)

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 2

ASPPClass · 0.90
ASPPDeformableClass · 0.90

Tested by

no test coverage detected