Closed Brion112233 closed 6 months ago
Just now,I visualized the pretrained model in modelzoo and the model changed.I find there is only dimensional difference between them in class_embed. So I read the bug in detail,and noticed that "Missing key(s) in state_dict" contains: Encoder,Decoder,Backbone,Mask_head and some embedding layers "Unexpected key(s) in state_dict" contains: Encoder,Decoder,Backbone and some embedding layers
Is there a problem with my steps?
I have found the reason!When training the box model,I add the content of 'resume' in the main.py,and I just forgot to delete it when training the seg head......
Instructions To Reproduce the 🐛 Bug:
git diff
) or what code you wrotethe code:
import torch pretrained_weights = torch.load('./weights/detr-r50-e632da11.pth')
num_classes: 5
num_class = 6 # num_classes + 1 pretrained_weights["model"]["classembed.weight"].resize(num_class+1, 256) pretrained_weights["model"]["classembed.bias"].resize(num_class+1) torch.save(pretrainedweights, "detr-r50%d.pth"%num_class)
when train the instance segmentation head,I used the command in the terminal:
python main.py --masks --epochs 25 --lr_drop 15 --coco_path /path/to/coco --frozen_weights /output/path/box_model/checkpoint.pth --output_dir /output/path/segm_model
Missing key(s) in state_dict: ......(A large string of text about the structure of the model ) Unexpected key(s) in state_dict: ......(A large string of text about the structure of the model )
PyTorch version: 1.10.1+cu113 Is debug build: False CUDA used to build PyTorch: 11.3 ROCM used to build PyTorch: N/A
Versions of relevant libraries: [pip3] numpy==1.21.6 [pip3] torch==1.10.1+cu113 [pip3] torch-tb-profiler==0.4.3 [pip3] torchaudio==0.10.1+cu113 [pip3] torchsummary==1.5.1 [pip3] torchvision==0.11.2+cu113 [conda] numpy 1.21.6 py37h976b520_0 conda-forge [conda] torch 1.10.1+cu113 pypi_0 pypi [conda] torch-tb-profiler 0.4.3 pypi_0 pypi [conda] torchaudio 0.10.1+cu113 pypi_0 pypi [conda] torchsummary 1.5.1 pypi_0 pypi [conda] torchvision 0.11.2+cu113 pypi_0 pypi