MCPcopy Create free account
hub / github.com/MotrixLab/ADHMR / _make_fuse_layers

Method _make_fuse_layers

ADHMR/lib/models/hrnet.py:189–244  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

187 return nn.ModuleList(branches)
188
189 def _make_fuse_layers(self):
190 if self.num_branches == 1:
191 return None
192
193 num_branches = self.num_branches
194 num_inchannels = self.num_inchannels
195 fuse_layers = []
196 for i in range(num_branches if self.multi_scale_output else 1):
197 fuse_layer = []
198 for j in range(num_branches):
199 if j > i:
200 fuse_layer.append(
201 nn.Sequential(
202 nn.Conv2d(
203 num_inchannels[j],
204 num_inchannels[i],
205 1, 1, 0, bias=False
206 ),
207 nn.BatchNorm2d(num_inchannels[i]),
208 nn.Upsample(scale_factor=2**(j - i), mode='nearest')
209 )
210 )
211 elif j == i:
212 fuse_layer.append(None)
213 else:
214 conv3x3s = []
215 for k in range(i - j):
216 if k == i - j - 1:
217 num_outchannels_conv3x3 = num_inchannels[i]
218 conv3x3s.append(
219 nn.Sequential(
220 nn.Conv2d(
221 num_inchannels[j],
222 num_outchannels_conv3x3,
223 3, 2, 1, bias=False
224 ),
225 nn.BatchNorm2d(num_outchannels_conv3x3)
226 )
227 )
228 else:
229 num_outchannels_conv3x3 = num_inchannels[j]
230 conv3x3s.append(
231 nn.Sequential(
232 nn.Conv2d(
233 num_inchannels[j],
234 num_outchannels_conv3x3,
235 3, 2, 1, bias=False
236 ),
237 nn.BatchNorm2d(num_outchannels_conv3x3),
238 nn.ReLU(True)
239 )
240 )
241 fuse_layer.append(nn.Sequential(*conv3x3s))
242 fuse_layers.append(nn.ModuleList(fuse_layer))
243
244 return nn.ModuleList(fuse_layers)
245
246 def get_num_inchannels(self):

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected