open-mmlab / mmsegmentation

OpenMMLab Semantic Segmentation Toolbox and Benchmark.
https://mmsegmentation.readthedocs.io/en/main/
Apache License 2.0
8.14k stars 2.59k forks source link

ResNeSt for CCNet ---KeyError: 'ResNeSt' #237

Closed xinfu607 closed 3 years ago

xinfu607 commented 3 years ago

Hi,I changed the backbone of CCNet (Resnet) to ResNeSt for my custom dataset. The error comes out. Could you please tell me the reason? The error and model are as followed:

Traceback (most recent call last): File "/code/image_segmentation/mmsegmentation/mmsegmentation/tools/train.py", line 184, in main() File "/code/image_segmentation/mmsegmentation/mmsegmentation/tools/train.py", line 153, in main cfg.model, train_cfg=cfg.train_cfg, test_cfg=cfg.test_cfg) File "/code/image_segmentation/mmsegmentation/mmsegmentation/mmseg/models/builder.py", line 56, in build_segmentor return build(cfg, SEGMENTORS, dict(train_cfg=train_cfg, test_cfg=test_cfg)) File "/code/image_segmentation/mmsegmentation/mmsegmentation/mmseg/models/builder.py", line 31, in build return build_from_cfg(cfg, registry, default_args) File "/opt/conda/lib/python3.6/site-packages/mmcv/utils/registry.py", line 171, in build_from_cfg return obj_cls(**args) File "/code/image_segmentation/mmsegmentation/mmsegmentation/mmseg/models/segmentors/encoder_decoder.py", line 39, in init self.init_weights(pretrained=pretrained) File "/code/image_segmentation/mmsegmentation/mmsegmentation/mmseg/models/segmentors/encoder_decoder.py", line 68, in init_weights self.backbone.init_weights(pretrained=pretrained) File "/code/image_segmentation/mmsegmentation/mmsegmentation/mmseg/models/backbones/resnet.py", line 609, in init_weights load_checkpoint(self, pretrained, strict=False, logger=logger) File "/opt/conda/lib/python3.6/site-packages/mmcv/runner/checkpoint.py", line 247, in load_checkpoint checkpoint = _load_checkpoint(filename, map_location) File "/opt/conda/lib/python3.6/site-packages/mmcv/runner/checkpoint.py", line 204, in _load_checkpoint model_url = model_urls[model_name] KeyError: 'ResNeSt'

Here is my model.

norm_cfg = dict(type='BN', requires_grad=True) ### SyncBN BN model = dict( type='EncoderDecoder', pretrained='open-mmlab://ResNeSt', backbone=dict( type='ResNeSt', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 2, 4), strides=(1, 2, 1, 1), norm_cfg=norm_cfg, norm_eval=False, style='pytorch', contract_dilation=True), decode_head=dict( type='CCHead', in_channels=2048, in_index=3, channels=512, recurrence=2, dropout_ratio=0.1, num_classes=124, norm_cfg=norm_cfg, align_corners=False, loss_decode=dict( type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), auxiliary_head=dict( type='FCNHead', in_channels=1024, in_index=2, channels=256, num_convs=1, concat_input=False, dropout_ratio=0.1, num_classes=124, norm_cfg=norm_cfg, align_corners=False, loss_decode=dict( type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) train_cfg = dict() test_cfg = dict(mode='whole')

YLyeliang commented 3 years ago

In your config file, the line:pretrained='open-mmlab://ResNeSt', ResNeSt is not a valid name, you should changed it to open-mmlab://resnest50

xinfu607 commented 3 years ago

Thanks a lot.