(self,
in_channels=3,
base_channels=64,
num_stages=5,
strides=(1, 1, 1, 1, 1),
enc_num_convs=(2, 2, 2, 2, 2),
dec_num_convs=(2, 2, 2, 2),
downsamples=(True, True, True, True),
enc_dilations=(1, 1, 1, 1, 1),
dec_dilations=(1, 1, 1, 1),
with_cp=False,
conv_cfg=None,
norm_cfg=dict(type='BN'),
act_cfg=dict(type='ReLU'),
upsample_cfg=dict(type='InterpConv'),
norm_eval=False,
dcn=None,
plugins=None,
pretrained=None,
init_cfg=None)
| 281 | """ |
| 282 | |
| 283 | def __init__(self, |
| 284 | in_channels=3, |
| 285 | base_channels=64, |
| 286 | num_stages=5, |
| 287 | strides=(1, 1, 1, 1, 1), |
| 288 | enc_num_convs=(2, 2, 2, 2, 2), |
| 289 | dec_num_convs=(2, 2, 2, 2), |
| 290 | downsamples=(True, True, True, True), |
| 291 | enc_dilations=(1, 1, 1, 1, 1), |
| 292 | dec_dilations=(1, 1, 1, 1), |
| 293 | with_cp=False, |
| 294 | conv_cfg=None, |
| 295 | norm_cfg=dict(type='BN'), |
| 296 | act_cfg=dict(type='ReLU'), |
| 297 | upsample_cfg=dict(type='InterpConv'), |
| 298 | norm_eval=False, |
| 299 | dcn=None, |
| 300 | plugins=None, |
| 301 | pretrained=None, |
| 302 | init_cfg=None): |
| 303 | super(UNet, self).__init__(init_cfg) |
| 304 | |
| 305 | self.pretrained = pretrained |
| 306 | assert not (init_cfg and pretrained), \ |
| 307 | 'init_cfg and pretrained cannot be setting at the same time' |
| 308 | if isinstance(pretrained, str): |
| 309 | warnings.warn('DeprecationWarning: pretrained is a deprecated, ' |
| 310 | 'please use "init_cfg" instead') |
| 311 | self.init_cfg = dict(type='Pretrained', checkpoint=pretrained) |
| 312 | elif pretrained is None: |
| 313 | if init_cfg is None: |
| 314 | self.init_cfg = [ |
| 315 | dict(type='Kaiming', layer='Conv2d'), |
| 316 | dict( |
| 317 | type='Constant', |
| 318 | val=1, |
| 319 | layer=['_BatchNorm', 'GroupNorm']) |
| 320 | ] |
| 321 | else: |
| 322 | raise TypeError('pretrained must be a str or None') |
| 323 | |
| 324 | assert dcn is None, 'Not implemented yet.' |
| 325 | assert plugins is None, 'Not implemented yet.' |
| 326 | assert len(strides) == num_stages, \ |
| 327 | 'The length of strides should be equal to num_stages, '\ |
| 328 | f'while the strides is {strides}, the length of '\ |
| 329 | f'strides is {len(strides)}, and the num_stages is '\ |
| 330 | f'{num_stages}.' |
| 331 | assert len(enc_num_convs) == num_stages, \ |
| 332 | 'The length of enc_num_convs should be equal to num_stages, '\ |
| 333 | f'while the enc_num_convs is {enc_num_convs}, the length of '\ |
| 334 | f'enc_num_convs is {len(enc_num_convs)}, and the num_stages is '\ |
| 335 | f'{num_stages}.' |
| 336 | assert len(dec_num_convs) == (num_stages-1), \ |
| 337 | 'The length of dec_num_convs should be equal to (num_stages-1), '\ |
| 338 | f'while the dec_num_convs is {dec_num_convs}, the length of '\ |
| 339 | f'dec_num_convs is {len(dec_num_convs)}, and the num_stages is '\ |
| 340 | f'{num_stages}.' |
no test coverage detected