CompositionalHumanParsing icon indicating copy to clipboard operation
CompositionalHumanParsing copied to clipboard

AttributeError: 'Namespace' object has no attribute 'num_classes' / Missing and Unexpected keys in state_dict

Open ge97qir opened this issue 5 years ago • 1 comments

I assume I have all the correct dependencies since I had errors before and resolved them by installing cuda 9.0 with gcc-5 and g++-5, but now I can not seem to solve this issue. When I run the evaluate.py script I get the following error:

Traceback (most recent call last):
  File "evaluate.py", line 234, in <module>
    main()
  File "evaluate.py", line 37, in main
    model = get_model(num_classes=args.num_classes)
AttributeError: 'Namespace' object has no attribute 'num_classes'

If I change the num_classes to anything but 7 I get the following err (this example is without putting in a parameter):

Traceback (most recent call last):
  File "evaluate.py", line 234, in <module>
    main()
  File "evaluate.py", line 41, in main
    model.load_state_dict(saved_state_dict, strict=False)
  File "/home/lukak/anaconda3/envs/CompositionalHumanParsing/lib/python3.6/site-packages/torch/nn/modules/module.py", line 719, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Stream:
	size mismatch for decoder.layer_dsn.3.weight: copying a param of torch.Size([20, 512, 1, 1]) from checkpoint, where the shape is torch.Size([7, 512, 1, 1]) in current model.
	size mismatch for decoder.layer_dsn.3.bias: copying a param of torch.Size([20]) from checkpoint, where the shape is torch.Size([7]) in current model.

When I change the num_classes to 7 I get the following err with long list of missing keys and unexpected keys:

Traceback (most recent call last):
  File "evaluate.py", line 234, in <module>
    main()
  File "evaluate.py", line 41, in main
    model.load_state_dict(saved_state_dict)
  File "/home/lukak/anaconda3/envs/CompositionalHumanParsing/lib/python3.6/site-packages/torch/nn/modules/module.py", line 719, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Stream:
	Missing key(s) in state_dict:  "decoder.layer5.b0.0.weight", "decoder.layer5.b0.1.weight", "decoder.layer5.b0.1.bias", ...
        .
        .
        .
        Unexpected key(s) in state_dict: "decoder.layer6.alpha", "decoder.layer6.conv0.0.weight", "decoder.layer6.conv0.1.weight", ...
        .
        .
        .

I have searched the internet for answers but found nothing that helped and as I am not an experienced software engineer any help would be appreciated.

ge97qir avatar Jan 14 '21 13:01 ge97qir

I also don't understand why there are 7 nodes in the final layer of the model, since there are 20 classes to identify. Is the model for download correct?

ge97qir avatar Jan 14 '21 18:01 ge97qir