Skip to content

Size mismatch for ssd_heads when using the pretrained model #62

Open
@QiqLiang

Description

@QiqLiang

Hi, I came up with an issue when training on my dataset which has 102 classes. It seems like a size mismatch problem when using the pretrained model.

Here is my code:
PYTHONWARNINGS="ignore" cvnets-train
--common.config-file config/detection/ssd_coco/coco-ssd-mobilevitv2-1.75.yaml
--common.results-loc exp/exp1
--common.override-kwargs model.detection.pretrained="ckpt/coco-ssd-mobilevitv2-1.75.pt" model.detection.n-classes=103

and this is the error:
2022-12-12 21:09:24 - ERROR - Unable to load pretrained weights from ckpt/coco-ssd-mobilevitv2-1.75.pt. Error: Error(s) in loading state_dict for SingleShotMaskDetector:
size mismatch for ssd_heads.0.loc_cls_layer.pw_conv.block.conv.weight: copying a param with shape torch.Size([510, 512, 1, 1]) from checkpoint, the shape in current model is torch.Size([642, 512, 1, 1]).
size mismatch for ssd_heads.0.loc_cls_layer.pw_conv.block.conv.bias: copying a param with shape torch.Size([510]) from checkpoint, the shape in current model is torch.Size([642]).
size mismatch for ssd_heads.1.loc_cls_layer.pw_conv.block.conv.weight: copying a param with shape torch.Size([510, 256, 1, 1]) from checkpoint, the shape in current model is torch.Size([642, 256, 1, 1]).
size mismatch for ssd_heads.1.loc_cls_layer.pw_conv.block.conv.bias: copying a param with shape torch.Size([510]) from checkpoint, the shape in current model is torch.Size([642]).
size mismatch for ssd_heads.2.loc_cls_layer.pw_conv.block.conv.weight: copying a param with shape torch.Size([510, 256, 1, 1]) from checkpoint, the shape in current model is torch.Size([642, 256, 1, 1]).
size mismatch for ssd_heads.2.loc_cls_layer.pw_conv.block.conv.bias: copying a param with shape torch.Size([510]) from checkpoint, the shape in current model is torch.Size([642]).
size mismatch for ssd_heads.3.loc_cls_layer.pw_conv.block.conv.weight: copying a param with shape torch.Size([510, 128, 1, 1]) from checkpoint, the shape in current model is torch.Size([642, 128, 1, 1]).
size mismatch for ssd_heads.3.loc_cls_layer.pw_conv.block.conv.bias: copying a param with shape torch.Size([510]) from checkpoint, the shape in current model is torch.Size([642]).
size mismatch for ssd_heads.4.loc_cls_layer.pw_conv.block.conv.weight: copying a param with shape torch.Size([510, 128, 1, 1]) from checkpoint, the shape in current model is torch.Size([642, 128, 1, 1]).
size mismatch for ssd_heads.4.loc_cls_layer.pw_conv.block.conv.bias: copying a param with shape torch.Size([510]) from checkpoint, the shape in current model is torch.Size([642]).
size mismatch for ssd_heads.5.loc_cls_layer.block.conv.weight: copying a param with shape torch.Size([340, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([428, 64, 1, 1]).
size mismatch for ssd_heads.5.loc_cls_layer.block.conv.bias: copying a param with shape torch.Size([340]) from checkpoint, the shape in current model is torch.Size([428]).

How to use the pretrained model when i try to train on my own dataset with different num_classes with mscoco?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions