Closed shc1104 closed 4 years ago
Question
Hi. I just pull the git repo today and I got the following error while running test.py. Looks like the "model.load_state_dict()" has some issue. Anyone knows why this happens? Thanks!
Additional context
Commnad:
python3 test.py --cfg yolov3-spp.cfg --weights weights/yolov3-spp-ultralytics.pt
Namespace(augment=False, batch_size=16, cfg='./cfg/yolov3-spp.cfg', conf_thres=0.001, data='data/coco2014.data', device='', img_size=512, iou_thres=0.6, save_json=True, single_cls=False, task='test', weights='weights/yolov3-spp-ultralytics.pt')
Model Summary: 225 layers, 6.29987e+07 parameters, 6.29987e+07 gradients, 118.0 GFLOPS
Error:
Traceback (most recent call last): File "test.py", line 263, in opt.augment) File "test.py", line 40, in test model.load_state_dict(torch.load(weights, map_location=device)['model']) File "/anaconda3/envs/pytorch-gpu/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1045, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for Darknet: Missing key(s) in state_dict: "total_ops", "total_params", "module_list.total_ops", "module_list.total_params", "module_list.0.total_ops", "module_list.0.total_params", "module_list.1.total_ops", "module_list.1.total_params", "module_list.2.total_ops", "module_list.2.total_params", "module_list.3.total_ops", "module_list.3.total_params", "module_list.4.total_ops", "module_list.4.total_params", "module_list.5.total_ops", "module_list.5.total_params", "module_list.6.total_ops", "module_list.6.total_params", "module_list.7.total_ops", "module_list.7.total_params", "module_list.8.total_ops", "module_list.8.total_params", "module_list.9.total_ops", "module_list.9.total_params", "module_list.10.total_ops", "module_list.10.total_params", "module_list.11.total_ops", "module_list.11.total_params", "module_list.12.total_ops", "module_list.12.total_params", "module_list.13.total_ops", "module_list.13.total_params", "module_list.14.total_ops", "module_list.14.total_params", "module_list.15.total_ops", "module_list.15.total_params", "module_list.16.total_ops", "module_list.16.total_params", "module_list.17.total_ops", "module_list.17.total_params", "module_list.18.total_ops", "module_list.18.total_params", "module_list.19.total_ops", "module_list.19.total_params", "module_list.20.total_ops", "module_list.20.total_params", "module_list.21.total_ops", "module_list.21.total_params", "module_list.22.total_ops", "module_list.22.total_params", "module_list.23.total_ops", "module_list.23.total_params", "module_list.24.total_ops", "module_list.24.total_params", "module_list.25.total_ops", "module_list.25.total_params", "module_list.26.total_ops", "module_list.26.total_params", "module_list.27.total_ops", "module_list.27.total_params", "module_list.28.total_ops", "module_list.28.total_params", "module_list.29.total_ops", "module_list.29.total_params", "module_list.30.total_ops", "module_list.30.total_params", "module_list.31.total_ops", "module_list.31.total_params", "module_list.32.total_ops", "module_list.32.total_params", "module_list.33.total_ops", "module_list.33.total_params", "module_list.34.total_ops", "module_list.34.total_params", "module_list.35.total_ops", "module_list.35.total_params", "module_list.36.total_ops", "module_list.36.total_params", "module_list.37.total_ops", "module_list.37.total_params", "module_list.38.total_ops", "module_list.38.total_params", "module_list.39.total_ops", "module_list.39.total_params", "module_list.40.total_ops", "module_list.40.total_params", "module_list.41.total_ops", "module_list.41.total_params", "module_list.42.total_ops", "module_list.42.total_params", "module_list.43.total_ops", "module_list.43.total_params", "module_list.44.total_ops", "module_list.44.total_params", "module_list.45.total_ops", "module_list.45.total_params", "module_list.46.total_ops", "module_list.46.total_params", "module_list.47.total_ops", "module_list.47.total_params", "module_list.48.total_ops", "module_list.48.total_params", "module_list.49.total_ops", "module_list.49.total_params", "module_list.50.total_ops", "module_list.50.total_params", "module_list.51.total_ops", "module_list.51.total_params", "module_list.52.total_ops", "module_list.52.total_params", "module_list.53.total_ops", "module_list.53.total_params", "module_list.54.total_ops", "module_list.54.total_params", "module_list.55.total_ops", "module_list.55.total_params", "module_list.56.total_ops", "module_list.56.total_params", "module_list.57.total_ops", "module_list.57.total_params", "module_list.58.total_ops", "module_list.58.total_params", "module_list.59.total_ops", "module_list.59.total_params", "module_list.60.total_ops", "module_list.60.total_params", "module_list.61.total_ops", "module_list.61.total_params", "module_list.62.total_ops", "module_list.62.total_params", "module_list.63.total_ops", "module_list.63.total_params", "module_list.64.total_ops", "module_list.64.total_params", "module_list.65.total_ops", "module_list.65.total_params", "module_list.66.total_ops", "module_list.66.total_params", "module_list.67.total_ops", "module_list.67.total_params", "module_list.68.total_ops", "module_list.68.total_params", "module_list.69.total_ops", "module_list.69.total_params", "module_list.70.total_ops", "module_list.70.total_params", "module_list.71.total_ops", "module_list.71.total_params", "module_list.72.total_ops", "module_list.72.total_params", "module_list.73.total_ops", "module_list.73.total_params", "module_list.74.total_ops", "module_list.74.total_params", "module_list.75.total_ops", "module_list.75.total_params", "module_list.76.total_ops", "module_list.76.total_params", "module_list.77.total_ops", "module_list.77.total_params", "module_list.79.total_ops", "module_list.79.total_params", "module_list.81.total_ops", "module_list.81.total_params", "module_list.83.total_ops", "module_list.83.total_params", "module_list.84.total_ops", "module_list.84.total_params", "module_list.85.total_ops", "module_list.85.total_params", "module_list.86.total_ops", "module_list.86.total_params", "module_list.87.total_ops", "module_list.87.total_params", "module_list.88.total_ops", "module_list.88.total_params", "module_list.89.total_ops", "module_list.89.total_params", "module_list.90.total_ops", "module_list.90.total_params", "module_list.91.total_ops", "module_list.91.total_params", "module_list.93.total_ops", "module_list.93.total_params", "module_list.94.total_ops", "module_list.94.total_params", "module_list.95.total_ops", "module_list.95.total_params", "module_list.96.total_ops", "module_list.96.total_params", "module_list.97.total_ops", "module_list.97.total_params", "module_list.98.total_ops", "module_list.98.total_params", "module_list.99.total_ops", "module_list.99.total_params", "module_list.100.total_ops", "module_list.100.total_params", "module_list.101.total_ops", "module_list.101.total_params", "module_list.102.total_ops", "module_list.102.total_params", "module_list.103.total_ops", "module_list.103.total_params", "module_list.105.total_ops", "module_list.105.total_params", "module_list.106.total_ops", "module_list.106.total_params", "module_list.107.total_ops", "module_list.107.total_params", "module_list.108.total_ops", "module_list.108.total_params", "module_list.109.total_ops", "module_list.109.total_params", "module_list.110.total_ops", "module_list.110.total_params", "module_list.111.total_ops", "module_list.111.total_params", "module_list.112.total_ops", "module_list.112.total_params", "module_list.113.total_ops", "module_list.113.total_params".
hello,i solved the problem,you should: pip3 uninstall thop or conda uninstall thop,because total_ops param was registed to the model, when you use htop get param or mac.in fact ,in the project ,in file utils/torch_utils.py try to use htop.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Uninstalling thop worked for me too. I tried both
pip uninstall thop
and
conda uninstall thop
@tonmoy-TS glad to hear that uninstalling thop resolved the issue for you as well! If you encounter any more issues or have further questions, feel free to ask. Happy coding!
Yup, Adding to it, thop removal worked for me too!
@BarathwajAnandan great to hear that removing thop resolved the issue for you too! If you have any more questions or need further assistance, feel free to ask. Happy coding!
❔Question
Hi. I just pull the git repo today and I got the following error while running test.py. Looks like the "model.load_state_dict()" has some issue. Anyone knows why this happens? Thanks!
Additional context
Commnad:
python3 test.py --cfg yolov3-spp.cfg --weights weights/yolov3-spp-ultralytics.pt
Namespace(augment=False, batch_size=16, cfg='./cfg/yolov3-spp.cfg', conf_thres=0.001, data='data/coco2014.data', device='', img_size=512, iou_thres=0.6, save_json=True, single_cls=False, task='test', weights='weights/yolov3-spp-ultralytics.pt')
Model Summary: 225 layers, 6.29987e+07 parameters, 6.29987e+07 gradients, 118.0 GFLOPS
Error:
Traceback (most recent call last): File "test.py", line 263, in
opt.augment)
File "test.py", line 40, in test
model.load_state_dict(torch.load(weights, map_location=device)['model'])
File "/anaconda3/envs/pytorch-gpu/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1045, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Darknet:
Missing key(s) in state_dict: "total_ops", "total_params", "module_list.total_ops", "module_list.total_params", "module_list.0.total_ops", "module_list.0.total_params", "module_list.1.total_ops", "module_list.1.total_params", "module_list.2.total_ops", "module_list.2.total_params", "module_list.3.total_ops", "module_list.3.total_params", "module_list.4.total_ops", "module_list.4.total_params", "module_list.5.total_ops", "module_list.5.total_params", "module_list.6.total_ops", "module_list.6.total_params", "module_list.7.total_ops", "module_list.7.total_params", "module_list.8.total_ops", "module_list.8.total_params", "module_list.9.total_ops", "module_list.9.total_params", "module_list.10.total_ops", "module_list.10.total_params", "module_list.11.total_ops", "module_list.11.total_params", "module_list.12.total_ops", "module_list.12.total_params", "module_list.13.total_ops", "module_list.13.total_params", "module_list.14.total_ops", "module_list.14.total_params", "module_list.15.total_ops", "module_list.15.total_params", "module_list.16.total_ops", "module_list.16.total_params", "module_list.17.total_ops", "module_list.17.total_params", "module_list.18.total_ops", "module_list.18.total_params", "module_list.19.total_ops", "module_list.19.total_params", "module_list.20.total_ops", "module_list.20.total_params", "module_list.21.total_ops", "module_list.21.total_params", "module_list.22.total_ops", "module_list.22.total_params", "module_list.23.total_ops", "module_list.23.total_params", "module_list.24.total_ops", "module_list.24.total_params", "module_list.25.total_ops", "module_list.25.total_params", "module_list.26.total_ops", "module_list.26.total_params", "module_list.27.total_ops", "module_list.27.total_params", "module_list.28.total_ops", "module_list.28.total_params", "module_list.29.total_ops", "module_list.29.total_params", "module_list.30.total_ops", "module_list.30.total_params", "module_list.31.total_ops", "module_list.31.total_params", "module_list.32.total_ops", "module_list.32.total_params", "module_list.33.total_ops", "module_list.33.total_params", "module_list.34.total_ops", "module_list.34.total_params", "module_list.35.total_ops", "module_list.35.total_params", "module_list.36.total_ops", "module_list.36.total_params", "module_list.37.total_ops", "module_list.37.total_params", "module_list.38.total_ops", "module_list.38.total_params", "module_list.39.total_ops", "module_list.39.total_params", "module_list.40.total_ops", "module_list.40.total_params", "module_list.41.total_ops", "module_list.41.total_params", "module_list.42.total_ops", "module_list.42.total_params", "module_list.43.total_ops", "module_list.43.total_params", "module_list.44.total_ops", "module_list.44.total_params", "module_list.45.total_ops", "module_list.45.total_params", "module_list.46.total_ops", "module_list.46.total_params", "module_list.47.total_ops", "module_list.47.total_params", "module_list.48.total_ops", "module_list.48.total_params", "module_list.49.total_ops", "module_list.49.total_params", "module_list.50.total_ops", "module_list.50.total_params", "module_list.51.total_ops", "module_list.51.total_params", "module_list.52.total_ops", "module_list.52.total_params", "module_list.53.total_ops", "module_list.53.total_params", "module_list.54.total_ops", "module_list.54.total_params", "module_list.55.total_ops", "module_list.55.total_params", "module_list.56.total_ops", "module_list.56.total_params", "module_list.57.total_ops", "module_list.57.total_params", "module_list.58.total_ops", "module_list.58.total_params", "module_list.59.total_ops", "module_list.59.total_params", "module_list.60.total_ops", "module_list.60.total_params", "module_list.61.total_ops", "module_list.61.total_params", "module_list.62.total_ops", "module_list.62.total_params", "module_list.63.total_ops", "module_list.63.total_params", "module_list.64.total_ops", "module_list.64.total_params", "module_list.65.total_ops", "module_list.65.total_params", "module_list.66.total_ops", "module_list.66.total_params", "module_list.67.total_ops", "module_list.67.total_params", "module_list.68.total_ops", "module_list.68.total_params", "module_list.69.total_ops", "module_list.69.total_params", "module_list.70.total_ops", "module_list.70.total_params", "module_list.71.total_ops", "module_list.71.total_params", "module_list.72.total_ops", "module_list.72.total_params", "module_list.73.total_ops", "module_list.73.total_params", "module_list.74.total_ops", "module_list.74.total_params", "module_list.75.total_ops", "module_list.75.total_params", "module_list.76.total_ops", "module_list.76.total_params", "module_list.77.total_ops", "module_list.77.total_params", "module_list.79.total_ops", "module_list.79.total_params", "module_list.81.total_ops", "module_list.81.total_params", "module_list.83.total_ops", "module_list.83.total_params", "module_list.84.total_ops", "module_list.84.total_params", "module_list.85.total_ops", "module_list.85.total_params", "module_list.86.total_ops", "module_list.86.total_params", "module_list.87.total_ops", "module_list.87.total_params", "module_list.88.total_ops", "module_list.88.total_params", "module_list.89.total_ops", "module_list.89.total_params", "module_list.90.total_ops", "module_list.90.total_params", "module_list.91.total_ops", "module_list.91.total_params", "module_list.93.total_ops", "module_list.93.total_params", "module_list.94.total_ops", "module_list.94.total_params", "module_list.95.total_ops", "module_list.95.total_params", "module_list.96.total_ops", "module_list.96.total_params", "module_list.97.total_ops", "module_list.97.total_params", "module_list.98.total_ops", "module_list.98.total_params", "module_list.99.total_ops", "module_list.99.total_params", "module_list.100.total_ops", "module_list.100.total_params", "module_list.101.total_ops", "module_list.101.total_params", "module_list.102.total_ops", "module_list.102.total_params", "module_list.103.total_ops", "module_list.103.total_params", "module_list.105.total_ops", "module_list.105.total_params", "module_list.106.total_ops", "module_list.106.total_params", "module_list.107.total_ops", "module_list.107.total_params", "module_list.108.total_ops", "module_list.108.total_params", "module_list.109.total_ops", "module_list.109.total_params", "module_list.110.total_ops", "module_list.110.total_params", "module_list.111.total_ops", "module_list.111.total_params", "module_list.112.total_ops", "module_list.112.total_params", "module_list.113.total_ops", "module_list.113.total_params".