Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python train.py --model danet --resume models/DANet101.pth.tar --dataset citys --backbone resnet101 --base-size 2080 --crop-size 1890 --batch-size 4 error #150

Open
yuki3304 opened this issue Oct 9, 2024 · 0 comments

Comments

@yuki3304
Copy link

yuki3304 commented Oct 9, 2024

I used the command python train.py --model danet --resume models/DANet101.pth.tar --dataset citys --backbone resnet101 --base-size 2080 --crop-size 1890 --batch-size 4

I tried running the command above to train the model myself. However, I encountered the following error.

Traceback (most recent call last):
File "train.py", line 280, in
trainer = Trainer(args)
File "train.py", line 161, in init
model = get_segmentation_model(args.model, dataset=args.dataset,
File "/opt/conda/lib/python3.8/site-packages/torch_encoding-1.2.2b20241007-py3.8.egg/encoding/models/sseg/init.py", line 24, in get_segmentation_model
return modelsname.lower()
File "/opt/conda/lib/python3.8/site-packages/torch_encoding-1.2.2b20241007-py3.8.egg/encoding/models/sseg/encnet.py", line 140, in get_encnet
model = EncNet(datasets[dataset.lower()].NUM_CLASS, backbone=backbone, root=root, **kwargs)
File "/opt/conda/lib/python3.8/site-packages/torch_encoding-1.2.2b20241007-py3.8.egg/encoding/models/sseg/encnet.py", line 23, in init
super(EncNet, self).init(nclass, backbone, aux, se_loss,
File "/opt/conda/lib/python3.8/site-packages/torch_encoding-1.2.2b20241007-py3.8.egg/encoding/models/sseg/base.py", line 69, in init
self.pretrained = get_backbone(backbone, pretrained=True, dilated=dilated,
File "/opt/conda/lib/python3.8/site-packages/torch_encoding-1.2.2b20241007-py3.8.egg/encoding/models/sseg/base.py", line 51, in get_backbone
net = modelsname
File "/opt/conda/lib/python3.8/site-packages/torch_encoding-1.2.2b20241007-py3.8.egg/encoding/models/backbone/resnet.py", line 349, in resnet50
model.load_state_dict(torch.load(
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1406, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
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]).

Do you know how to fix the error? I used the Cityscapes dataset.

@yuki3304 yuki3304 changed the title python train.py --dataset citys --backbone resnet50 --epochs 300 --batch-size 4 error python train.py --model danet --dataset citys --backbone resnet50 --epochs 300 --batch-size 4 error Oct 16, 2024
@yuki3304 yuki3304 changed the title python train.py --model danet --dataset citys --backbone resnet50 --epochs 300 --batch-size 4 error python train.py --model danet --resume models/DANet101.pth.tar --dataset citys --backbone resnet101 --base-size 2080 --crop-size 1890 --batch-size 4 error Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant