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

我在加载预训练模型时出现了问题 #36

Open
overweighted opened this issue Mar 22, 2024 · 1 comment
Open

我在加载预训练模型时出现了问题 #36

overweighted opened this issue Mar 22, 2024 · 1 comment

Comments

@overweighted
Copy link

我使用的命令是python test.py --gpu 0 --workdir ./output --model sparenet --weights ./ckpt/SpareNet.pth--test_mode default
下面是我截取的一小段报错:
Traceback (most recent call last):
File "test.py", line 80, in
main()
File "test.py", line 74, in main
model = getattr(module, args.model + "Runner")(cfg, logger)
File "/media/jsj/1E44E67244E64C59/jsc/SpareNet/runners/sparenet_runner.py", line 19, in init
super().init(config, logger)
File "/media/jsj/1E44E67244E64C59/jsc/SpareNet/runners/base_runner.py", line 79, in init
self.models_load()
File "/media/jsj/1E44E67244E64C59/jsc/SpareNet/runners/base_runner.py", line 108, in models_load
self.init_epoch, self.best_metrics = um.model_load(self.config, self.models)
File "/media/jsj/1E44E67244E64C59/jsc/SpareNet/utils/misc.py", line 75, in model_load
net_G.load_state_dict(checkpoint["net_G"]) # change into net_G!!
File "/home/jsj/anaconda3/envs/jsc/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1605, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for DataParallel:
Unexpected key(s) in state_dict: "module.encoder.feat_extractor.se1.fc.0.weight", "module.encoder.feat_extractor.se1.fc.2.weight",

尝试过修改 net_G.load_state_dict(checkpoint["net_G"],strict=False),但是输出效果很差,请问有什么好的办法吗

@AlphaPav
Copy link
Contributor

您好,

可能是版本问题, 请问您的torch版本是什么? 可参考requirements.txt里的版本.

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

2 participants