C-3-Framework
C-3-Framework copied to clipboard
Missing key(s) in state_dict: "CCN.frontend.0.weight",Unexpected key(s) in state_dict: "CCN.module.frontend.0.weight"
python test.py
Traceback (most recent call last):
File "test.py", line 153, in
remove the "module."
where to remove,the module is in the model 07-CSRNet_all_ep_39_mae_32.6_mse_74.3.pth?
https://github.com/gjy3035/C-3-Framework/issues/22#issuecomment-494287652
where to remove,the module is in the model 07-CSRNet_all_ep_39_mae_32.6_mse_74.3.pth? try this:
from collections import OrderedDict
import torch
model_in = 'model_in.pth'
statedict = torch.load(model_in)
statedict_new = OrderedDict()
for statekey in statedict:
statekey_new = statekey.replace('.module','')
statedict_new[statekey_new] = statedict[statekey]
torch.save(statedict_new, 'model_out.pth')
where to remove,the module is in the model 07-CSRNet_all_ep_39_mae_32.6_mse_74.3.pth? try this:
from collections import OrderedDict import torch model_in = 'model_in.pth' statedict = torch.load(model_in) statedict_new = OrderedDict() for statekey in statedict: statekey_new = statekey.replace('.module','') statedict_new[statekey_new] = statedict[statekey] torch.save(statedict_new, 'model_out.pth')
thank you!!