MCPcopy Create free account
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / FTB

Class FTB

lib/network_auxi.py:100–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98
99
100class FTB(nn.Module):
101 def __init__(self, inchannels, midchannels=512):
102 super(FTB, self).__init__()
103 self.in1 = inchannels
104 self.mid = midchannels
105 self.conv1 = nn.Conv2d(in_channels=self.in1, out_channels=self.mid, kernel_size=3, padding=1, stride=1,
106 bias=True)
107 # NN.BatchNorm2d
108 self.conv_branch = nn.Sequential(nn.ReLU(inplace=True), \
109 nn.Conv2d(in_channels=self.mid, out_channels=self.mid, kernel_size=3,
110 padding=1, stride=1, bias=True), \
111 nn.BatchNorm2d(num_features=self.mid), \
112 nn.ReLU(inplace=True), \
113 nn.Conv2d(in_channels=self.mid, out_channels=self.mid, kernel_size=3,
114 padding=1, stride=1, bias=True))
115 self.relu = nn.ReLU(inplace=True)
116
117 self.init_params()
118
119 def forward(self, x):
120 x = self.conv1(x)
121 x = x + self.conv_branch(x)
122 x = self.relu(x)
123
124 return x
125
126 def init_params(self):
127 for m in self.modules():
128 if isinstance(m, nn.Conv2d):
129 init.normal_(m.weight, std=0.01)
130 if m.bias is not None:
131 init.constant_(m.bias, 0)
132 elif isinstance(m, nn.ConvTranspose2d):
133 # init.kaiming_normal_(m.weight, mode='fan_out')
134 init.normal_(m.weight, std=0.01)
135 # init.xavier_normal_(m.weight)
136 if m.bias is not None:
137 init.constant_(m.bias, 0)
138 elif isinstance(m, nn.BatchNorm2d): # NN.BatchNorm2d
139 init.constant_(m.weight, 1)
140 init.constant_(m.bias, 0)
141 elif isinstance(m, nn.Linear):
142 init.normal_(m.weight, std=0.01)
143 if m.bias is not None:
144 init.constant_(m.bias, 0)
145
146
147class ATA(nn.Module):

Callers 2

__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected