Swin-Transformer icon indicating copy to clipboard operation
Swin-Transformer copied to clipboard

How can I load a "swin_large_patch4_window7_224_22k" model?

Open garlicman-man opened this issue 3 years ago • 4 comments

Actually, I successfully load the small type and base type model by --resume. But when I want to use large model, I get a message that: "size mismatch for head.bias: copying a param with shape torch.Size([21841]) from checkpoint, the shape in current model is torch.Size([1000])."

garlicman-man avatar Jul 26 '21 11:07 garlicman-man

Has this been resolved? Or is there currently no support for training a Swin-L model? I know we need both the pth file and the python config file. I see config files for tiny, small, and base but none for large. Can we use a config like configs/swin/cascade_mask_rcnn_swin_base_patch4_window7_mstrain_480-800_giou_4conv1f_adamw_3x_coco.py with swin_large_patch4_window7_224_22k and have it work correctly?

MatthewCodes avatar Aug 20 '21 16:08 MatthewCodes

你要把checkpoint里不匹配的扔掉

cwq63 avatar Oct 27 '21 09:10 cwq63

Hi, friend, I have solved it. When you init the swin_transformer.SwinTransformer() , you need to set the num_classes as 21841 instead of 1000(it is default) , because it is "22k" model. Good luck for you !

zgj-gutou avatar Nov 06 '21 02:11 zgj-gutou

@zgj-gutou @cwq63 Perhaps my problem is same for theirs? I'm using my dataset & change some part which can work well in ‘Swin-Transformer-Semantic-Segmentation ’code but show me errors in mmsegmentation swin code(with official pretrain model ‘upernet_swin_tiny_patch4_window7_512x512.pth’): size mismatch for stages.0.downsample.norm.weight: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([192]). size mismatch for stages.0.downsample.norm.bias: copying a param with shape torch.Size([384]) from checkpoint, the shape in current model is torch.Size([192]).

Thanks for your help.

Lsz-20 avatar Nov 10 '21 12:11 Lsz-20