pytorch-semseg icon indicating copy to clipboard operation
pytorch-semseg copied to clipboard

test.py error

Open yong6600 opened this issue 5 years ago • 2 comments

I have trouble when test.py command I want solve that this problem

This is test.py command

python test.py --model_path ./runs/fcn16s_cityscapes_best_model.pkl --img_path ~/dataset/cityscape/leftImg8bit/test/berlin/berlin_000197_000019_leftImg8bit.png --out_path ./out/

error

File "test.py", line 157, in test(args) File "test.py", line 60, in test model.load_state_dict(state) File "/home/yong/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py", line 777, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for fcn16s: size mismatch for classifier.6.weight: copying a param with shape torch.Size([19, 4096, 1, 1]) from checkpoint, the shape in current model is torch.Size([21, 4096, 1, 1]). size mismatch for classifier.6.bias: copying a param with shape torch.Size([19]) from checkpoint, the shape in current model is torch.Size([21]). size mismatch for score_pool4.weight: copying a param with shape torch.Size([19, 512, 1, 1]) from checkpoint, the shape in current model is torch.Size([21, 512, 1, 1]). size mismatch for score_pool4.bias: copying a param with shape torch.Size([19]) from checkpoint, the shape in current model is torch.Size([21]).

yong6600 avatar May 11 '19 15:05 yong6600

Did you figure out the answer to your question? I ran into a similar error.

callmediddy avatar Jun 02 '19 23:06 callmediddy

21 means the n_classes parameter in test.py, you can change it from 21 to 19 manually to fix the error.

givenjiang avatar Jun 20 '19 07:06 givenjiang