mixfacenets icon indicating copy to clipboard operation
mixfacenets copied to clipboard

Errors in loading state_dict for MixNet when trying to run eval.py

Open milech opened this issue 10 months ago • 2 comments

Running eval.py with 147836backbone.pth, as hardcoded in the eval.py script, for any of the six models (MixFaceNet-M, ShuffleMixFaceNet-M, MixFaceNet-S, ShuffleMixFaceNet-S, MixFaceNet-XS, ShuffleMixFaceNet-XS) throws the following exception:

Exception has occurred: RuntimeError
Error(s) in loading state_dict for MixNet:
	size mismatch for tail.conv.weight: copying a param with shape torch.Size([1024, 200, 1, 1]) from checkpoint, the shape in current model is torch.Size([512, 200, 1, 1]).
	size mismatch for tail.bn.weight: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([512]).
	size mismatch for tail.bn.bias: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([512]).
	size mismatch for tail.bn.running_mean: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([512]).
	size mismatch for tail.bn.running_var: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([512]).
	size mismatch for tail.activ.weight: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([512]).
	size mismatch for feautre_layer.dw_conv.conv.weight: copying a param with shape torch.Size([1024, 1, 7, 7]) from checkpoint, the shape in current model is torch.Size([512, 1, 7, 7]).
	size mismatch for feautre_layer.dw_conv.bn.weight: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([512]).
	size mismatch for feautre_layer.dw_conv.bn.bias: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([512]).
	size mismatch for feautre_layer.dw_conv.bn.running_mean: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([512]).
	size mismatch for feautre_layer.dw_conv.bn.running_var: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([512]).
	size mismatch for feautre_layer.pw_conv.conv.weight: copying a param with shape torch.Size([512, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([512, 512, 1, 1]).
  File "/user/mlech/codes/mixfacenets/eval.py", line 31, in <module>
    backbone.load_state_dict(torch.load(os.path.join('models','147836backbone.pth'),map_location=torch.device('cpu')))
RuntimeError: Error(s) in loading state_dict for MixNet:
	size mismatch for tail.conv.weight: copying a param with shape torch.Size([1024, 200, 1, 1]) from checkpoint, the shape in current model is torch.Size([512, 200, 1, 1]).
	size mismatch for tail.bn.weight: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([512]).
	size mismatch for tail.bn.bias: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([512]).
	size mismatch for tail.bn.running_mean: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([512]).
	size mismatch for tail.bn.running_var: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([512]).
	size mismatch for tail.activ.weight: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([512]).
	size mismatch for feautre_layer.dw_conv.conv.weight: copying a param with shape torch.Size([1024, 1, 7, 7]) from checkpoint, the shape in current model is torch.Size([512, 1, 7, 7]).
	size mismatch for feautre_layer.dw_conv.bn.weight: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([512]).
	size mismatch for feautre_layer.dw_conv.bn.bias: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([512]).
	size mismatch for feautre_layer.dw_conv.bn.running_mean: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([512]).
	size mismatch for feautre_layer.dw_conv.bn.running_var: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([512]).
	size mismatch for feautre_layer.pw_conv.conv.weight: copying a param with shape torch.Size([512, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([512, 512, 1, 1]).

milech avatar Apr 08 '24 18:04 milech

Have you got any fix for this? I'm having the same issue.

Heatseeker-3 avatar May 06 '24 20:05 Heatseeker-3

Not sure whether you're asking me or the author, I haven't tried to fix that.

milech avatar May 08 '24 07:05 milech