speedinghzl / pytorch-segmentation-toolbox

PyTorch Implementations for DeeplabV3 and PSPNet
MIT License
768 stars 167 forks source link

error in evaluation.py #15

Closed amiltonwong closed 5 years ago

amiltonwong commented 5 years ago

Hi, @speedinghzl ,

I had succeeded in training Deeplab_v3 model (iterations=400 for preliminary model) for cityscapes dataset. However, when I perform evaluation for cityscapes by:

python evaluate.py --restore-from ./snapshots/CS_scenes_400.pth --data-dir /data/cityscapes_dataset

I came across the following error:

root@milton-ThinkCentre-M93p:/data/code8/pytorch-segmentation-toolbox# python evaluate.py --restore-from ./snapshots/CS_scenes_400.pth --data-dir /data/cityscapes_dataset
Traceback (most recent call last):
  File "evaluate.py", line 253, in <module>
    main()
  File "evaluate.py", line 199, in main
    model.load_state_dict(saved_state_dict)
  File "/root/anaconda3/envs/tf1.3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 721, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for ResNet:
    Missing key(s) in state_dict: "head.0.stages.0.1.weight", "head.0.stages.0.2.weight", "head.0.stages.0.2.bias", "head.0.stages.0.2.running_mean", "head.0.stages.0.2.running_var", "head.0.stages.1.1.weight", "head.0.stages.1.2.weight", "head.0.stages.1.2.bias", "head.0.stages.1.2.running_mean", "head.0.stages.1.2.running_var", "head.0.stages.2.1.weight", "head.0.stages.2.2.weight", "head.0.stages.2.2.bias", "head.0.stages.2.2.running_mean", "head.0.stages.2.2.running_var", "head.0.stages.3.1.weight", "head.0.stages.3.2.weight", "head.0.stages.3.2.bias", "head.0.stages.3.2.running_mean", "head.0.stages.3.2.running_var". 
    Unexpected key(s) in state_dict: "head.0.conv1.1.weight", "head.0.conv1.2.weight", "head.0.conv1.2.bias", "head.0.conv1.2.running_mean", "head.0.conv1.2.running_var", "head.0.conv2.0.weight", "head.0.conv2.1.weight", "head.0.conv2.1.bias", "head.0.conv2.1.running_mean", "head.0.conv2.1.running_var", "head.0.conv3.0.weight", "head.0.conv3.1.weight", "head.0.conv3.1.bias", "head.0.conv3.1.running_mean", "head.0.conv3.1.running_var", "head.0.conv4.0.weight", "head.0.conv4.1.weight", "head.0.conv4.1.bias", "head.0.conv4.1.running_mean", "head.0.conv4.1.running_var", "head.0.conv5.0.weight", "head.0.conv5.1.weight", "head.0.conv5.1.bias", "head.0.conv5.1.running_mean", "head.0.conv5.1.running_var". 
    While copying the parameter named "head.0.bottleneck.0.weight", whose dimensions in the model are torch.Size([512, 4096, 3, 3]) and whose dimensions in the checkpoint are torch.Size([512, 1280, 1, 1]).

Any suggestion to fix it?

THX!

speedinghzl commented 5 years ago

Have you switched to import deeplabv3 model in evaluate.py? @amiltonwong