open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.56k stars 9.46k forks source link

Size mismatch for roi_head with coco pretrained model #10617

Open liebeslied opened 1 year ago

liebeslied commented 1 year ago

Hi,

I know there have been issues/requests in the past about size mismatch issues when finetuning a detection model using a different number of classes from the original (e.g. https://github.com/open-mmlab/mmdetection/issues/743), but I'm unclear on what the resolution is.

I have updated the classes in my dataloaders and the num_classes param where it appears in the base model configuration, according to the finetuning tutorial. I'm finetuning the Cascade R-101-FPN DCN model from here.

I'm still receiving these warnings (for example, where 100 is the number of classes I want to use and 80 is the number in the pretrained model):

size mismatch for roi_head.bbox_head.0.fc_cls.weight: copying a param with shape torch.Size([81, 1024]) from checkpoint, the shape in current model is torch.Size([101, 1024]).
size mismatch for roi_head.bbox_head.0.fc_cls.bias: copying a param with shape torch.Size([81]) from checkpoint, the shape in current model is torch.Size([101]).
size mismatch for roi_head.bbox_head.1.fc_cls.weight: copying a param with shape torch.Size([81, 1024]) from checkpoint, the shape in current model is torch.Size([101, 1024]).
size mismatch for roi_head.bbox_head.1.fc_cls.bias: copying a param with shape torch.Size([81]) from checkpoint, the shape in current model is torch.Size([101]).
size mismatch for roi_head.bbox_head.2.fc_cls.weight: copying a param with shape torch.Size([81, 1024]) from checkpoint, the shape in current model is torch.Size([101, 1024]).
size mismatch for roi_head.bbox_head.2.fc_cls.bias: copying a param with shape torch.Size([81]) from checkpoint, the shape in current model is torch.Size([101]).

Are these warnings expected? If not, should I try to resize the layer as suggested in the issue from 2019, or do something different?

Thanks!

1andDone commented 1 year ago

@liebeslied ever figure this out?

liebeslied commented 1 year ago

I think I just did nothing about it.