swiftnet
swiftnet copied to clipboard
state_dict load error when evaluating
I want to evaluate a SPECIFIED Image using your method, how should I do?
-
After downloading two file "swiftnet_pyr_cs.pt" and "swiftnet_ss_cs.pt" from the link https://drive.google.com/drive/folders/1DqX-N-nMtGG9QfMY_cKtULCKTfEuV4WT you give in README.md
-
I edit the file configs/rn18_single_scale.py to switch the evaluating to
Trueand load the pre-trained model in this way:
67 if evaluating:
68 model.load_state_dict(torch.load('weights/swiftnet_ss_cs.pt'))
69 # model.load_state_dict(torch.load('weights/rn18_single_scale/model_best.pt'))
70 else:
71 model.criterion = SemsegCrossEntropy(num_classes=num_classes, ignore_id=ignore_id)
72 lr = 4e-4
73 lr_min = 1e-6
74 fine_tune_factor = 4
75 weight_decay = 1e-4
76 epochs = 250
- then run this cmd for evaluation:
python eval.py configs/rn18_single_scale.pybut I got some state_dict errors:
RuntimeError: Error(s) in loading state_dict for SemsegModel:
Missing key(s) in state_dict: "backbone.img_mean", "backbone.img_std", "logits.conv.bias".
size mismatch for logits.conv.weight: copying a param with shape torch.Size([19, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([19, 128, 1, 1]).
- So I change the pre-trained model I ever load in configs/rn18_single_scale.py from
swiftnet_ss_cs.pttoswiftnet_pyr_cs.ptand then run last step: 3, I still got some state_dict error:
RuntimeError: Error(s) in loading state_dict for SemsegModel:
Missing key(s) in state_dict:
……
Unexpected key(s) in state_dict:
……
size mismatch for logits.conv.weight: copying a param with shape torch.Size([19, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([19, 128, 1, 1]).
So, how should I do to evaluate a Specified Image?
Same error