RuntimeError: Error(s) in loading state_dict for DLASeg

@ptrblck : Any help would be much appreciated.

I have setup the same environment, and I am trying to load pretrained model “model_mot.pth” to get the state_dict().
But I am getting an error:

Unexpected key(s) in state_dict: “ltrb_amodal.0.weight”, “ltrb_amodal.0.bias”, “ltrb_amodal.2.weight”, “ltrb_amodal.2.bias”, “base.pre_hm_layer.0.weight”, “base.pre_hm_layer.1.weight”, “base.pre_hm_layer.1.bias”, “base.pre_hm_layer.1.running_mean”, “base.pre_hm_layer.1.running_var”, “base.pre_hm_layer.1.num_batches_tracked”.

The above keys are already available in state_dict_util. using pytorch 1.5.0


model_path  = 'models/model_mot.pth'
model = create_model(opt.arch, opt.heads, opt.head_conv, opt=opt)
dummy_input = Variable(torch.randn(1, 1, 544, 960))
state_dict_util = torch.load(model_path, map_location="cpu")['state_dict']
new_state_dict = OrderedDict()
for k, v in state_dict_util.items():
    new_state_dict[k] = v
torch_model = model.load_state_dict(new_state_dict)
# torch_model = model.load_state_dict(torch.load(model_path)['state_dict'], strict=False)
torch.onnx.export(torch_model, dummy_input, "models/model_mot.onnx")

There seems to be a naming conflict in the loaded state_dict and your module names.
You could check both via:

for name, module in model.named_modules():

sd = model.state_dict()
for key in sd:

and see what the names should look like.

PS: please don’t tag specific people, as it could discourage others to post an answer :wink: