Closed daigang896 closed 3 years ago
It's a bug,just remove the argument. use the script to transfer checkpoint from swin to mmseg manually.
https://github.com/open-mmlab/mmsegmentation/blob/master/tools/model_converters/swin2mmseg.py
Hi, it is a bug and we would fix it as soon as possible.
Best,
Hi, if you use the latest version of MMSeg, this 'pretrain_style' has been deprecated thus no bug would meet.
I used a model from mmsegmentation, the bug still existed. mmcv 1.3.8 mmsegmentation 0.17.0 python 3.7.11
code:
config_file = '../configs/swin/upernet_swin_base_patch4_window7_512x512_160k_ade20k_pretrain_224x224_1K.py'
checkpoint_file = '../checkpoints/upernet_swin_base_patch4_window7_512x512_160k_ade20k_pretrain_224x224_1K_20210526_192340-593b0e13.pth'
model = init_segmentor(config_file, checkpoint_file, device='cuda:0')
error:
TypeError: SwinTransformer: __init__() got an unexpected keyword argument 'pretrain_style'
I used a model from mmsegmentation, the bug still existed. mmcv 1.3.8 mmsegmentation 0.17.0 python 3.7.11
code:
config_file = '../configs/swin/upernet_swin_base_patch4_window7_512x512_160k_ade20k_pretrain_224x224_1K.py' checkpoint_file = '../checkpoints/upernet_swin_base_patch4_window7_512x512_160k_ade20k_pretrain_224x224_1K_20210526_192340-593b0e13.pth' model = init_segmentor(config_file, checkpoint_file, device='cuda:0')
error:
TypeError: SwinTransformer: __init__() got an unexpected keyword argument 'pretrain_style'
pretrain_style
has been deprecated in the latest version.
I used a model from mmsegmentation, the bug still existed. mmcv 1.3.8 mmsegmentation 0.17.0 python 3.7.11 code:
config_file = '../configs/swin/upernet_swin_base_patch4_window7_512x512_160k_ade20k_pretrain_224x224_1K.py' checkpoint_file = '../checkpoints/upernet_swin_base_patch4_window7_512x512_160k_ade20k_pretrain_224x224_1K_20210526_192340-593b0e13.pth' model = init_segmentor(config_file, checkpoint_file, device='cuda:0')
error:
TypeError: SwinTransformer: __init__() got an unexpected keyword argument 'pretrain_style'
pretrain_style
has been deprecated in the latest version.
The latest version is 0.17.0, isn't it ?
I got it wrong before. It's better to remove pretrain_style
in https://github.com/open-mmlab/mmsegmentation/blob/4d8229c141ae4f971b978a58c6b2861c59955fce/configs/swin/upernet_swin_tiny_patch4_window7_512x512_160k_ade20k_pretrain_224x224_1K.py#L15 and https://github.com/open-mmlab/mmsegmentation/blob/4d8229c141ae4f971b978a58c6b2861c59955fce/configs/_base_/models/upernet_swin.py#L27
We will fix it in this PR.
TypeError: EncoderDecoder: SwinTransformer: init() got an unexpected keyword argument 'pretrain_style'. mmcv.version='1.3.12' mmseg.version'0.17.0' Python 3.6.13
whole code: from mmseg.apis import inference_segmentor, init_segmentor from mmcv import Config import cv2
config_path = 'configs/swin/upernet_swin_base_patch4_window7_512x512_160k_ade20k_pretrain_224x224_1K.py' checkpoint = 'swin_base_models/upernet_swin_base_patch4_window7_512x512_160k_ade20k_pretrain_224x224_1K_20210526_192340-593b0e13.pth' cfg = Config.fromfile(config_path) model = init_segmentor(cfg, checkpoint, device='cuda:0') img = cv2.imread('demo.jpg') result = inference_segmentor(model, img) print(result)