-
Notifications
You must be signed in to change notification settings - Fork 6
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
Unexpected key(s) in state_dict: "heads.sample_x_indexs", "heads.prior_feat_ys", "heads.prior_ys", "heads.criterion.weight". #3
Comments
You did not successfully replace the clr_head.py file. |
Thanks @xuanandsix. It seems to be the clr_head.py from this repo is being indeed loaded. |
1、By 'pip list' check if the path to the 'clrnet' package is correct. A log has been upload here https://github.com/xuanandsix/CLRNet-onnxruntime-and-tensorrt-demo/blob/main/my_log/test_onnx.log |
Hi @xuanandsix, I notice: In your example "python torch2onnx.py configs/clrnet/clr_resnet18_tusimple.py --load_from tusimple_r18.pth", But I have these when I load my trained model. So maybe this is why you are not getting my crash that I list in this issue. What do you think? |
@sahamitul Have you solved this problem? |
same issues,any advices? |
@mengxia1994 maybe you can try other backbone. I met this problem when use resnet-18, but it worked when I use dla 34. |
I found that exporting seems to work ok if I use the pretraining weights provided by https://github.com/Turoad/clrnet but if I train my own network, I get this error, with both dla34-culane and resnet18-tusimple. Not sure what's different |
OK I got this working literally just by deleting the offending dict keys:
inserted just before
Edit. probably better to do as @AshwinAKannan suggests with
|
I passed 'strict=False' model = load_state_dict(path, strict=False) |
Hi,
I run:
python torch2onnx.py <config_file> --load_from <pth_file>
and get crash:-
pretrained model: https://download.pytorch.org/models/resnet101-5d3b4d8f.pth
Traceback (most recent call last):
File "torch2onnx.py", line 49, in
main()
File "torch2onnx.py", line 28, in main
net.load_state_dict(new_state_dict)
File "/home/msaha/anaconda3/envs/clrnet/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1223, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for Detector:
Unexpected key(s) in state_dict: "heads.sample_x_indexs", "heads.prior_feat_ys", "heads.prior_ys", "heads.criterion.weight".
Any ideas? @xuanandsix
Thanks!
The text was updated successfully, but these errors were encountered: