When run test_single_image,RuntimeError: Error(s) in loading state_dict for ResNet
tinaZZer opened this issue · 3 comments
D:\code\FastFCN>python3 -m experiments.segmentation.test_single_image
Namespace(aux=False, aux_weight=0.2, backbone='resnet50', base_size=520, batch_size=16, checkname='default', crop_size=480, cuda=True, dataset='ade20k', dilated=False, epochs=120, ft=False, input_path='D:/code/FastFCN/test/pic', jpu=None, lateral=False, lr=0.01, lr_scheduler='poly', mode='testval', model='encnet', model_zoo=None, momentum=0.9, ms=False, no_cuda=False, no_val=False, resume=None, save_folder='experiments/segmentation/results', save_path='D:/code/FastFCN/test/result', se_loss=False, se_weight=0.2, seed=1, split='val', start_epoch=0, test_batch_size=16, train_split='train', weight_decay=0.0001, workers=16)
Traceback (most recent call last):
File "D:\python3\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "D:\python3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "D:\code\FastFCN\experiments\segmentation\test_single_image.py", line 71, in
test(args)
File "D:\code\FastFCN\experiments\segmentation\test_single_image.py", line 36, in test
base_size = args.base_size, crop_size = args.crop_size)
File "D:\code\FastFCN\encoding\models_init.py", line 18, in get_segmentation_model
return modelsname.lower()
File "D:\code\FastFCN\encoding\models\encnet.py", line 146, in get_encnet
model = EncNet(datasets[dataset.lower()].NUM_CLASS, backbone=backbone, root=root, **kwargs)
File "D:\code\FastFCN\encoding\models\encnet.py", line 24, in init
norm_layer=norm_layer, **kwargs)
File "D:\code\FastFCN\encoding\models\base.py", line 39, in init
norm_layer=norm_layer, root=root)
File "D:\code\FastFCN\encoding\dilated\resnet.py", line 263, in resnet50
get_model_file('resnet50', root=root)), strict=False)
File "D:\python3\lib\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 ResNet:
size mismatch for bn1.weight: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for bn1.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for bn1.running_mean: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for bn1.running_var: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for layer1.0.conv1.weight: copying a param with shape torch.Size([64, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([64, 128, 1, 1]).
size mismatch for layer1.0.downsample.0.weight: copying a param with shape torch.Size([256, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([256, 128, 1, 1]).
pytorch=1.1.0
Is it the problem with the Pytorch version?
Thank a lot!
After set pretrained=False, the following error occurred, i am new to pytorch.
How to set resume ? Thanks a lot!
Traceback (most recent call last):
File "D:/code/FastFCN/experiments/segmentation/test_single_image.py", line 71, in
test(args)
File "D:/code/FastFCN/experiments/segmentation/test_single_image.py", line 39, in test
raise RuntimeError("=> no checkpoint found at '{}'" .format(args.resume))
RuntimeError: => no checkpoint found at '{D:/code/FastFCN/model/encnet_jpu_res50_pcontext.pth.tar}'
Do you set --resume [MODEL_PATH]
?