MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / __init__

Method __init__

detrsmpl/models/backbones/hrnet.py:233–372  ·  view source on GitHub ↗
(self,
                 extra,
                 in_channels=3,
                 conv_cfg=None,
                 norm_cfg=dict(type='BN'),
                 norm_eval=True,
                 with_cp=False,
                 num_joints=24,
                 zero_init_residual=False,
                 multiscale_output=True,
                 pretrained=None,
                 init_cfg=None)

Source from the content-addressed store, hash-verified

231 blocks_dict = {'BASIC': BasicBlock, 'BOTTLENECK': Bottleneck}
232
233 def __init__(self,
234 extra,
235 in_channels=3,
236 conv_cfg=None,
237 norm_cfg=dict(type='BN'),
238 norm_eval=True,
239 with_cp=False,
240 num_joints=24,
241 zero_init_residual=False,
242 multiscale_output=True,
243 pretrained=None,
244 init_cfg=None):
245 super(PoseHighResolutionNet, self).__init__(init_cfg)
246
247 self.pretrained = pretrained
248 assert not (init_cfg and pretrained), \
249 'init_cfg and pretrained cannot be specified at the same time'
250 if isinstance(pretrained, str):
251 warnings.warn('DeprecationWarning: pretrained is deprecated, '
252 'please use "init_cfg" instead')
253 self.init_cfg = dict(type='Pretrained', checkpoint=pretrained)
254 elif pretrained is None:
255 if init_cfg is None:
256 self.init_cfg = [
257 dict(type='Kaiming', layer='Conv2d'),
258 dict(type='Constant',
259 val=1,
260 layer=['_BatchNorm', 'GroupNorm'])
261 ]
262 else:
263 raise TypeError('pretrained must be a str or None')
264
265 # Assert configurations of 4 stages are in extra
266 assert 'stage1' in extra and 'stage2' in extra \
267 and 'stage3' in extra and 'stage4' in extra
268 # Assert whether the length of `num_blocks` and `num_channels` are
269 # equal to `num_branches`
270 for i in range(4):
271 cfg = extra[f'stage{i + 1}']
272 assert len(cfg['num_blocks']) == cfg['num_branches'] and \
273 len(cfg['num_channels']) == cfg['num_branches']
274
275 self.extra = extra
276 self.conv_cfg = conv_cfg
277 self.norm_cfg = norm_cfg
278 self.norm_eval = norm_eval
279 self.with_cp = with_cp
280 self.zero_init_residual = zero_init_residual
281
282 # stem net
283 self.norm1_name, norm1 = build_norm_layer(self.norm_cfg, 64, postfix=1)
284 self.norm2_name, norm2 = build_norm_layer(self.norm_cfg, 64, postfix=2)
285
286 self.conv1 = build_conv_layer(self.conv_cfg,
287 in_channels,
288 64,
289 kernel_size=3,
290 stride=2,

Callers

nothing calls this directly

Calls 6

_make_layerMethod · 0.95
_make_stageMethod · 0.95
_make_upsample_layerMethod · 0.95
__init__Method · 0.45

Tested by

no test coverage detected