DrSleep / DenseTorch

An easy-to-use wrapper for work with dense per-pixel tasks in PyTorch (including multi-task learning)
MIT License
62 stars 8 forks source link

Missing Keys in state_dict ; Unexpected keys in state_dict #14

Open shahaamirbader opened 2 years ago

shahaamirbader commented 2 years ago

Great work. I have tried to train a NYUD joint network using default settings provided in the repo. The model is saved as checkpoint.pth.tar.

However, when running the inference using one of the notebook code from https://github.com/DrSleep/multi-task-refinenet/blob/master/src/notebooks/ExpNYUD_joint.ipynb, I get the subject error as follows:


(MTLRefineNet) [ashah29@compute-0-3 notebooks]$ python ExpNYUD_joint.py
Traceback (most recent call last):
  File "ExpNYUD_joint.py", line 44, in <module>
    model.load_state_dict(ckpt['state_dict'])
  File "/project/xfu/aamir/anaconda3/envs/MTLRefineNet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1483, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Net:
        Missing key(s) in state_dict: "layer1.0.weight", "layer1.1.weight", "layer1.1.bias", "layer1.1.running_mean", "layer1.1.running_var", "layer2.0.output.0.0.weight", "layer2.0.output.0.1.weight", "layer2.0.output.0.1.bias", "layer2.0.output.0.1.running_mean", "layer2.0.output.0.1.running_var", "layer2.0.output.1.0.weight", "layer2.0.output.1.1.weight", "layer2.0.output.1.1.bias", "layer2.0.output.1.1.running_mean", "layer2.0.output.1.1.running_var", "layer2.0.output.2.0.weight", "layer2.0.output.2.1.weight", "layer2.0.output.2.1.bias", "layer2.0.output.2.1.running_mean", "layer2.0.output.2.1.running_var", "layer3.0.output.0.0.weight", "layer3.0.output.0.1.weight", "layer3.0.output.0.1.bias", "layer3.0.output.0.1.running_mean", "layer3.0.output.0.1.running_var", "layer3.0.output.1.0.weight", "layer3.0.output.1.1.weight", "layer3.0.output.1.1.bias", "layer3.0.output.1.1.running_mean", "layer3.0.output.1.1.running_var", "layer3.0.output.2.0.weight", "layer3.0.output.2.1.weight", "layer3.0.output.2.1.bias", "layer3.0.output.2.1.running_mean", "layer3.0.output.2.1.running_var", "layer3.1.output.0.0.weight", "layer3.1.output.0.1.weight", "layer3.1.output.0.1.bias", "layer3.1.output.0.1.running_mean", "layer3.1.output.0.1.running_var", "layer3.1.output.1.0.weight", "layer3.1.output.1.1.weight", "layer3.1.output.1.1.bias", "layer3.1.output.1.1.running_mean", "layer3.1.output.1.1.running_var", "layer3.1.output.2.0.weight", "layer3.1.output.2.1.weight", "layer3.1.output.2.1.bias", "layer3.1.output.2.1.running_mean", "layer3.1.output.2.1.running_var", "layer4.0.output.0.0.weight", "layer4.0.output.0.1.weight", "layer4.0.output.0.1.bias", "layer4.0.output.0.1.running_mean", "layer4.0.output.0.1.running_var", "layer4.0.output.1.0.weight", "layer4.0.output.1.1.weight", "layer4.0.output.1.1.bias", "layer4.0.output.1.1.running_mean", "layer4.0.output.1.1.running_var", "layer4.0.output.2.0.weight", "layer4.0.output.2.1.weight", "layer4.0.output.2.1.bias", "layer4.0.output.2.1.running_mean", "layer4.0.output.2.1.running_var", "layer4.1.output.0.0.weight", "layer4.1.output.0.1.weight", "layer4.1.output.0.1.bias", "layer4.1.output.0.1.running_mean", "layer4.1.output.0.1.running_var", "layer4.1.output.1.0.weight", "layer4.1.output.1.1.weight", "layer4.1.output.1.1.bias", "layer4.1.output.1.1.running_mean", "layer4.1.output.1.1.running_var", "layer4.1.output.2.0.weight", "layer4.1.output.2.1.weight", "layer4.1.output.2.1.bias", "layer4.1.output.2.1.running_mean", "layer4.1.output.2.1.running_var", "layer4.2.output.0.0.weight", "layer4.2.output.0.1.weight", "layer4.2.output.0.1.bias", "layer4.2.output.0.1.running_mean", "layer4.2.output.0.1.running_var", "layer4.2.output.1.0.weight", "layer4.2.output.1.1.weight", "layer4.2.output.1.1.bias", "layer4.2.output.1.1.running_mean", "layer4.2.output.1.1.running_var", "layer4.2.output.2.0.weight", "layer4.2.output.2.1.weight", "layer4.2.output.2.1.bias", "layer4.2.output.2.1.running_mean", "layer4.2.output.2.1.running_var", "layer5.0.output.0.0.weight", "layer5.0.output.0.1.weight", "layer5.0.output.0.1.bias", "layer5.0.output.0.1.running_mean", "layer5.0.output.0.1.running_var", "layer5.0.output.1.0.weight", "layer5.0.output.1.1.weight", "layer5.0.output.1.1.bias", "layer5.0.output.1.1.running_mean", "layer5.0.output.1.1.running_var", "layer5.0.output.2.0.weight", "layer5.0.output.2.1.weight", "layer5.0.output.2.1.bias", "layer5.0.output.2.1.running_mean", "layer5.0.output.2.1.running_var", "layer5.1.output.0.0.weight", "layer5.1.output.0.1.weight", "layer5.1.output.0.1.bias", "layer5.1.output.0.1.running_mean", "layer5.1.output.0.1.running_var", "layer5.1.output.1.0.weight", "layer5.1.output.1.1.weight", "layer5.1.output.1.1.bias", "layer5.1.output.1.1.running_mean", "layer5.1.output.1.1.running_var", "layer5.1.output.2.0.weight", "layer5.1.output.2.1.weight", "layer5.1.output.2.1.bias", "layer5.1.output.2.1.running_mean", "layer5.1.output.2.1.running_var", "layer5.2.output.0.0.weight", "layer5.2.output.0.1.weight", "layer5.2.output.0.1.bias", "layer5.2.output.0.1.running_mean", "layer5.2.output.0.1.running_var", "layer5.2.output.1.0.weight", "layer5.2.output.1.1.weight", "layer5.2.output.1.1.bias", "layer5.2.output.1.1.running_mean", "layer5.2.output.1.1.running_var", "layer5.2.output.2.0.weight", "layer5.2.output.2.1.weight", "layer5.2.output.2.1.bias", "layer5.2.output.2.1.running_mean", "layer5.2.output.2.1.running_var", "layer5.3.output.0.0.weight", "layer5.3.output.0.1.weight", "layer5.3.output.0.1.bias", "layer5.3.output.0.1.running_mean", "layer5.3.output.0.1.running_var", "layer5.3.output.1.0.weight", "layer5.3.output.1.1.weight", "layer5.3.output.1.1.bias", "layer5.3.output.1.1.running_mean", "layer5.3.output.1.1.running_var", "layer5.3.output.2.0.weight", "layer5.3.output.2.1.weight", "layer5.3.output.2.1.bias", "layer5.3.output.2.1.running_mean", "layer5.3.output.2.1.running_var", "layer6.0.output.0.0.weight", "layer6.0.output.0.1.weight", "layer6.0.output.0.1.bias", "layer6.0.output.0.1.running_mean", "layer6.0.output.0.1.running_var", "layer6.0.output.1.0.weight", "layer6.0.output.1.1.weight", "layer6.0.output.1.1.bias", "layer6.0.output.1.1.running_mean", "layer6.0.output.1.1.running_var", "layer6.0.output.2.0.weight", "layer6.0.output.2.1.weight", "layer6.0.output.2.1.bias", "layer6.0.output.2.1.running_mean", "layer6.0.output.2.1.running_var", "layer6.1.output.0.0.weight", "layer6.1.output.0.1.weight", "layer6.1.output.0.1.bias", "layer6.1.output.0.1.running_mean", "layer6.1.output.0.1.running_var", "layer6.1.output.1.0.weight", "layer6.1.output.1.1.weight", "layer6.1.output.1.1.bias", "layer6.1.output.1.1.running_mean", "layer6.1.output.1.1.running_var", "layer6.1.output.2.0.weight", "layer6.1.output.2.1.weight", "layer6.1.output.2.1.bias", "layer6.1.output.2.1.running_mean", "layer6.1.output.2.1.running_var", "layer6.2.output.0.0.weight", "layer6.2.output.0.1.weight", "layer6.2.output.0.1.bias", "layer6.2.output.0.1.running_mean", "layer6.2.output.0.1.running_var", "layer6.2.output.1.0.weight", "layer6.2.output.1.1.weight", "layer6.2.output.1.1.bias", "layer6.2.output.1.1.running_mean", "layer6.2.output.1.1.running_var", "layer6.2.output.2.0.weight", "layer6.2.output.2.1.weight", "layer6.2.output.2.1.bias", "layer6.2.output.2.1.running_mean", "layer6.2.output.2.1.running_var", "layer7.0.output.0.0.weight", "layer7.0.output.0.1.weight", "layer7.0.output.0.1.bias", "layer7.0.output.0.1.running_mean", "layer7.0.output.0.1.running_var", "layer7.0.output.1.0.weight", "layer7.0.output.1.1.weight", "layer7.0.output.1.1.bias", "layer7.0.output.1.1.running_mean", "layer7.0.output.1.1.running_var", "layer7.0.output.2.0.weight", "layer7.0.output.2.1.weight", "layer7.0.output.2.1.bias", "layer7.0.output.2.1.running_mean", "layer7.0.output.2.1.running_var", "layer7.1.output.0.0.weight", "layer7.1.output.0.1.weight", "layer7.1.output.0.1.bias", "layer7.1.output.0.1.running_mean", "layer7.1.output.0.1.running_var", "layer7.1.output.1.0.weight", "layer7.1.output.1.1.weight", "layer7.1.output.1.1.bias", "layer7.1.output.1.1.running_mean", "layer7.1.output.1.1.running_var", "layer7.1.output.2.0.weight", "layer7.1.output.2.1.weight", "layer7.1.output.2.1.bias", "layer7.1.output.2.1.running_mean", "layer7.1.output.2.1.running_var", "layer7.2.output.0.0.weight", "layer7.2.output.0.1.weight", "layer7.2.output.0.1.bias", "layer7.2.output.0.1.running_mean", "layer7.2.output.0.1.running_var", "layer7.2.output.1.0.weight", "layer7.2.output.1.1.weight", "layer7.2.output.1.1.bias", "layer7.2.output.1.1.running_mean", "layer7.2.output.1.1.running_var", "layer7.2.output.2.0.weight", "layer7.2.output.2.1.weight", "layer7.2.output.2.1.bias", "layer7.2.output.2.1.running_mean", "layer7.2.output.2.1.running_var", "layer8.0.output.0.0.weight", "layer8.0.output.0.1.weight", "layer8.0.output.0.1.bias", "layer8.0.output.0.1.running_mean", "layer8.0.output.0.1.running_var", "layer8.0.output.1.0.weight", "layer8.0.output.1.1.weight", "layer8.0.output.1.1.bias", "layer8.0.output.1.1.running_mean", "layer8.0.output.1.1.running_var", "layer8.0.output.2.0.weight", "layer8.0.output.2.1.weight", "layer8.0.output.2.1.bias", "layer8.0.output.2.1.running_mean", "layer8.0.output.2.1.running_var", "conv8.weight", "conv7.weight", "conv6.weight", "conv5.weight", "conv4.weight", "conv3.weight", "crp4.0.1_outvar_dimred.weight", "crp4.0.2_outvar_dimred.weight", "crp4.0.3_outvar_dimred.weight", "crp4.0.4_outvar_dimred.weight", "crp3.0.1_outvar_dimred.weight", "crp3.0.2_outvar_dimred.weight", "crp3.0.3_outvar_dimred.weight", "crp3.0.4_outvar_dimred.weight", "crp2.0.1_outvar_dimred.weight", "crp2.0.2_outvar_dimred.weight", "crp2.0.3_outvar_dimred.weight", "crp2.0.4_outvar_dimred.weight", "crp1.0.1_outvar_dimred.weight", "crp1.0.2_outvar_dimred.weight", "crp1.0.3_outvar_dimred.weight", "crp1.0.4_outvar_dimred.weight", "conv_adapt4.weight", "conv_adapt3.weight", "conv_adapt2.weight", "pre_depth.weight", "depth.weight", "depth.bias", "pre_segm.weight", "segm.weight", "segm.bias".
        Unexpected key(s) in state_dict: "module.0.layer1.0.weight", "module.0.layer1.1.weight", "module.0.layer1.1.bias", "module.0.layer1.1.running_mean", "module.0.layer1.1.running_var", "module.0.layer1.1.num_batches_tracked", "module.0.layer2.0.output.0.0.weight", "module.0.layer2.0.output.0.1.weight", "module.0.layer2.0.output.0.1.bias", "module.0.layer2.0.output.0.1.running_mean", "module.0.layer2.0.output.0.1.running_var", "module.0.layer2.0.output.0.1.num_batches_tracked", "module.0.layer2.0.output.1.0.weight", "module.0.layer2.0.output.1.1.weight", "module.0.layer2.0.output.1.1.bias", "module.0.layer2.0.output.1.1.running_mean", "module.0.layer2.0.output.1.1.running_var", "module.0.layer2.0.output.1.1.num_batches_tracked", "module.0.layer2.0.output.2.0.weight", "module.0.layer2.0.output.2.1.weight", "module.0.layer2.0.output.2.1.bias", "module.0.layer2.0.output.2.1.running_mean", "module.0.layer2.0.output.2.1.running_var", "module.0.layer2.0.output.2.1.num_batches_tracked", "module.0.layer3.0.output.0.0.weight", "module.0.layer3.0.output.0.1.weight", "module.0.layer3.0.output.0.1.bias", "module.0.layer3.0.output.0.1.running_mean", "module.0.layer3.0.output.0.1.running_var", "module.0.layer3.0.output.0.1.num_batches_tracked", "module.0.layer3.0.output.1.0.weight", "module.0.layer3.0.output.1.1.weight", "module.0.layer3.0.output.1.1.bias", "module.0.layer3.0.output.1.1.running_mean", "module.0.layer3.0.output.1.1.running_var", "module.0.layer3.0.output.1.1.num_batches_tracked", "module.0.layer3.0.output.2.0.weight", "module.0.layer3.0.output.2.1.weight", "module.0.layer3.0.output.2.1.bias", "module.0.layer3.0.output.2.1.running_mean", "module.0.layer3.0.output.2.1.running_var", "module.0.layer3.0.output.2.1.num_batches_tracked", "module.0.layer3.1.output.0.0.weight", "module.0.layer3.1.output.0.1.weight", "module.0.layer3.1.output.0.1.bias", "module.0.layer3.1.output.0.1.running_mean", "module.0.layer3.1.output.0.1.running_var", "module.0.layer3.1.output.0.1.num_batches_tracked", "module.0.layer3.1.output.1.0.weight", "module.0.layer3.1.output.1.1.weight", "module.0.layer3.1.output.1.1.bias", "module.0.layer3.1.output.1.1.running_mean", "module.0.layer3.1.output.1.1.running_var", "module.0.layer3.1.output.1.1.num_batches_tracked", "module.0.layer3.1.output.2.0.weight", "module.0.layer3.1.output.2.1.weight", "module.0.layer3.1.output.2.1.bias", "module.0.layer3.1.output.2.1.running_mean", "module.0.layer3.1.output.2.1.running_var", "module.0.layer3.1.output.2.1.num_batches_tracked", "module.0.layer4.0.output.0.0.weight", "module.0.layer4.0.output.0.1.weight", "module.0.layer4.0.output.0.1.bias", "module.0.layer4.0.output.0.1.running_mean", "module.0.layer4.0.output.0.1.running_var", "module.0.layer4.0.output.0.1.num_batches_tracked", "module.0.layer4.0.output.1.0.weight", "module.0.layer4.0.output.1.1.weight", "module.0.layer4.0.output.1.1.bias", "module.0.layer4.0.output.1.1.running_mean", "module.0.layer4.0.output.1.1.running_var", "module.0.layer4.0.output.1.1.num_batches_tracked", "module.0.layer4.0.output.2.0.weight", "module.0.layer4.0.output.2.1.weight", "module.0.layer4.0.output.2.1.bias", "module.0.layer4.0.output.2.1.running_mean", "module.0.layer4.0.output.2.1.running_var", "module.0.layer4.0.output.2.1.num_batches_tracked", "module.0.layer4.1.output.0.0.weight", "module.0.layer4.1.output.0.1.weight", "module.0.layer4.1.output.0.1.bias", "module.0.layer4.1.output.0.1.running_mean", "module.0.layer4.1.output.0.1.running_var", "module.0.layer4.1.output.0.1.num_batches_tracked", "module.0.layer4.1.output.1.0.weight", "module.0.layer4.1.output.1.1.weight", "module.0.layer4.1.output.1.1.bias", "module.0.layer4.1.output.1.1.running_mean", "module.0.layer4.1.output.1.1.running_var", "module.0.layer4.1.output.1.1.num_batches_tracked", "module.0.layer4.1.output.2.0.weight", "module.0.layer4.1.output.2.1.weight", "module.0.layer4.1.output.2.1.bias", "module.0.layer4.1.output.2.1.running_mean", "module.0.layer4.1.output.2.1.running_var", "module.0.layer4.1.output.2.1.num_batches_tracked", "module.0.layer4.2.output.0.0.weight", "module.0.layer4.2.output.0.1.weight", "module.0.layer4.2.output.0.1.bias", "module.0.layer4.2.output.0.1.running_mean", "module.0.layer4.2.output.0.1.running_var", "module.0.layer4.2.output.0.1.num_batches_tracked", "module.0.layer4.2.output.1.0.weight", "module.0.layer4.2.output.1.1.weight", "module.0.layer4.2.output.1.1.bias", "module.0.layer4.2.output.1.1.running_mean", "module.0.layer4.2.output.1.1.running_var", "module.0.layer4.2.output.1.1.num_batches_tracked", "module.0.layer4.2.output.2.0.weight", "module.0.layer4.2.output.2.1.weight", "module.0.layer4.2.output.2.1.bias", "module.0.layer4.2.output.2.1.running_mean", "module.0.layer4.2.output.2.1.running_var", "module.0.layer4.2.output.2.1.num_batches_tracked", "module.0.layer5.0.output.0.0.weight", "module.0.layer5.0.output.0.1.weight", "module.0.layer5.0.output.0.1.bias", "module.0.layer5.0.output.0.1.running_mean", "module.0.layer5.0.output.0.1.running_var", "module.0.layer5.0.output.0.1.num_batches_tracked", "module.0.layer5.0.output.1.0.weight", "module.0.layer5.0.output.1.1.weight", "module.0.layer5.0.output.1.1.bias", "module.0.layer5.0.output.1.1.running_mean", "module.0.layer5.0.output.1.1.running_var", "module.0.layer5.0.output.1.1.num_batches_tracked", "module.0.layer5.0.output.2.0.weight", "module.0.layer5.0.output.2.1.weight", "module.0.layer5.0.output.2.1.bias", "module.0.layer5.0.output.2.1.running_mean", "module.0.layer5.0.output.2.1.running_var", "module.0.layer5.0.output.2.1.num_batches_tracked", "module.0.layer5.1.output.0.0.weight", "module.0.layer5.1.output.0.1.weight", "module.0.layer5.1.output.0.1.bias", "module.0.layer5.1.output.0.1.running_mean", "module.0.layer5.1.output.0.1.running_var", "module.0.layer5.1.output.0.1.num_batches_tracked", "module.0.layer5.1.output.1.0.weight", "module.0.layer5.1.output.1.1.weight", "module.0.layer5.1.output.1.1.bias", "module.0.layer5.1.output.1.1.running_mean", "module.0.layer5.1.output.1.1.running_var", "module.0.layer5.1.output.1.1.num_batches_tracked", "module.0.layer5.1.output.2.0.weight", "module.0.layer5.1.output.2.1.weight", "module.0.layer5.1.output.2.1.bias", "module.0.layer5.1.output.2.1.running_mean", "module.0.layer5.1.output.2.1.running_var", "module.0.layer5.1.output.2.1.num_batches_tracked", "module.0.layer5.2.output.0.0.weight", "module.0.layer5.2.output.0.1.weight", "module.0.layer5.2.output.0.1.bias", "module.0.layer5.2.output.0.1.running_mean", "module.0.layer5.2.output.0.1.running_var", "module.0.layer5.2.output.0.1.num_batches_tracked", "module.0.layer5.2.output.1.0.weight", "module.0.layer5.2.output.1.1.weight", "module.0.layer5.2.output.1.1.bias", "module.0.layer5.2.output.1.1.running_mean", "module.0.layer5.2.output.1.1.running_var", "module.0.layer5.2.output.1.1.num_batches_tracked", "module.0.layer5.2.output.2.0.weight", "module.0.layer5.2.output.2.1.weight", "module.0.layer5.2.output.2.1.bias", "module.0.layer5.2.output.2.1.running_mean", "module.0.layer5.2.output.2.1.running_var", "module.0.layer5.2.output.2.1.num_batches_tracked", "module.0.layer5.3.output.0.0.weight", "module.0.layer5.3.output.0.1.weight", "module.0.layer5.3.output.0.1.bias", "module.0.layer5.3.output.0.1.running_mean", "module.0.layer5.3.output.0.1.running_var", "module.0.layer5.3.output.0.1.num_batches_tracked", "module.0.layer5.3.output.1.0.weight", "module.0.layer5.3.output.1.1.weight", "module.0.layer5.3.output.1.1.bias", "module.0.layer5.3.output.1.1.running_mean", "module.0.layer5.3.output.1.1.running_var", "module.0.layer5.3.output.1.1.num_batches_tracked", "module.0.layer5.3.output.2.0.weight", "module.0.layer5.3.output.2.1.weight", "module.0.layer5.3.output.2.1.bias", "module.0.layer5.3.output.2.1.running_mean", "module.0.layer5.3.output.2.1.running_var", "module.0.layer5.3.output.2.1.num_batches_tracked", "module.0.layer6.0.output.0.0.weight", "module.0.layer6.0.output.0.1.weight", "module.0.layer6.0.output.0.1.bias", "module.0.layer6.0.output.0.1.running_mean", "module.0.layer6.0.output.0.1.running_var", "module.0.layer6.0.output.0.1.num_batches_tracked", "module.0.layer6.0.output.1.0.weight", "module.0.layer6.0.output.1.1.weight", "module.0.layer6.0.output.1.1.bias", "module.0.layer6.0.output.1.1.running_mean", "module.0.layer6.0.output.1.1.running_var", "module.0.layer6.0.output.1.1.num_batches_tracked", "module.0.layer6.0.output.2.0.weight", "module.0.layer6.0.output.2.1.weight", "module.0.layer6.0.output.2.1.bias", "module.0.layer6.0.output.2.1.running_mean", "module.0.layer6.0.output.2.1.running_var", "module.0.layer6.0.output.2.1.num_batches_tracked", "module.0.layer6.1.output.0.0.weight", "module.0.layer6.1.output.0.1.weight", "module.0.layer6.1.output.0.1.bias", "module.0.layer6.1.output.0.1.running_mean", "module.0.layer6.1.output.0.1.running_var", "module.0.layer6.1.output.0.1.num_batches_tracked", "module.0.layer6.1.output.1.0.weight", "module.0.layer6.1.output.1.1.weight", "module.0.layer6.1.output.1.1.bias", "module.0.layer6.1.output.1.1.running_mean", "module.0.layer6.1.output.1.1.running_var", "module.0.layer6.1.output.1.1.num_batches_tracked", "module.0.layer6.1.output.2.0.weight", "module.0.layer6.1.output.2.1.weight", "module.0.layer6.1.output.2.1.bias", "module.0.layer6.1.output.2.1.running_mean", "module.0.layer6.1.output.2.1.running_var", "module.0.layer6.1.output.2.1.num_batches_tracked", "module.0.layer6.2.output.0.0.weight", "module.0.layer6.2.output.0.1.weight", "module.0.layer6.2.output.0.1.bias", "module.0.layer6.2.output.0.1.running_mean", "module.0.layer6.2.output.0.1.running_var", "module.0.layer6.2.output.0.1.num_batches_tracked", "module.0.layer6.2.output.1.0.weight", "module.0.layer6.2.output.1.1.weight", "module.0.layer6.2.output.1.1.bias", "module.0.layer6.2.output.1.1.running_mean", "module.0.layer6.2.output.1.1.running_var", "module.0.layer6.2.output.1.1.num_batches_tracked", "module.0.layer6.2.output.2.0.weight", "module.0.layer6.2.output.2.1.weight", "module.0.layer6.2.output.2.1.bias", "module.0.layer6.2.output.2.1.running_mean", "module.0.layer6.2.output.2.1.running_var", "module.0.layer6.2.output.2.1.num_batches_tracked", "module.0.layer7.0.output.0.0.weight", "module.0.layer7.0.output.0.1.weight", "module.0.layer7.0.output.0.1.bias", "module.0.layer7.0.output.0.1.running_mean", "module.0.layer7.0.output.0.1.running_var", "module.0.layer7.0.output.0.1.num_batches_tracked", "module.0.layer7.0.output.1.0.weight", "module.0.layer7.0.output.1.1.weight", "module.0.layer7.0.output.1.1.bias", "module.0.layer7.0.output.1.1.running_mean", "module.0.layer7.0.output.1.1.running_var", "module.0.layer7.0.output.1.1.num_batches_tracked", "module.0.layer7.0.output.2.0.weight", "module.0.layer7.0.output.2.1.weight", "module.0.layer7.0.output.2.1.bias", "module.0.layer7.0.output.2.1.running_mean", "module.0.layer7.0.output.2.1.running_var", "module.0.layer7.0.output.2.1.num_batches_tracked", "module.0.layer7.1.output.0.0.weight", "module.0.layer7.1.output.0.1.weight", "module.0.layer7.1.output.0.1.bias", "module.0.layer7.1.output.0.1.running_mean", "module.0.layer7.1.output.0.1.running_var", "module.0.layer7.1.output.0.1.num_batches_tracked", "module.0.layer7.1.output.1.0.weight", "module.0.layer7.1.output.1.1.weight", "module.0.layer7.1.output.1.1.bias", "module.0.layer7.1.output.1.1.running_mean", "module.0.layer7.1.output.1.1.running_var", "module.0.layer7.1.output.1.1.num_batches_tracked", "module.0.layer7.1.output.2.0.weight", "module.0.layer7.1.output.2.1.weight", "module.0.layer7.1.output.2.1.bias", "module.0.layer7.1.output.2.1.running_mean", "module.0.layer7.1.output.2.1.running_var", "module.0.layer7.1.output.2.1.num_batches_tracked", "module.0.layer7.2.output.0.0.weight", "module.0.layer7.2.output.0.1.weight", "module.0.layer7.2.output.0.1.bias", "module.0.layer7.2.output.0.1.running_mean", "module.0.layer7.2.output.0.1.running_var", "module.0.layer7.2.output.0.1.num_batches_tracked", "module.0.layer7.2.output.1.0.weight", "module.0.layer7.2.output.1.1.weight", "module.0.layer7.2.output.1.1.bias", "module.0.layer7.2.output.1.1.running_mean", "module.0.layer7.2.output.1.1.running_var", "module.0.layer7.2.output.1.1.num_batches_tracked", "module.0.layer7.2.output.2.0.weight", "module.0.layer7.2.output.2.1.weight", "module.0.layer7.2.output.2.1.bias", "module.0.layer7.2.output.2.1.running_mean", "module.0.layer7.2.output.2.1.running_var", "module.0.layer7.2.output.2.1.num_batches_tracked", "module.0.layer8.0.output.0.0.weight", "module.0.layer8.0.output.0.1.weight", "module.0.layer8.0.output.0.1.bias", "module.0.layer8.0.output.0.1.running_mean", "module.0.layer8.0.output.0.1.running_var", "module.0.layer8.0.output.0.1.num_batches_tracked", "module.0.layer8.0.output.1.0.weight", "module.0.layer8.0.output.1.1.weight", "module.0.layer8.0.output.1.1.bias", "module.0.layer8.0.output.1.1.running_mean", "module.0.layer8.0.output.1.1.running_var", "module.0.layer8.0.output.1.1.num_batches_tracked", "module.0.layer8.0.output.2.0.weight", "module.0.layer8.0.output.2.1.weight", "module.0.layer8.0.output.2.1.bias", "module.0.layer8.0.output.2.1.running_mean", "module.0.layer8.0.output.2.1.running_var", "module.0.layer8.0.output.2.1.num_batches_tracked", "module.1.stem_convs.0.weight", "module.1.stem_convs.1.weight", "module.1.stem_convs.2.weight", "module.1.stem_convs.3.weight", "module.1.stem_convs.4.weight", "module.1.stem_convs.5.weight", "module.1.crp_blocks.0.0.1_outvar_dimred.weight", "module.1.crp_blocks.0.0.2_outvar_dimred.weight", "module.1.crp_blocks.0.0.3_outvar_dimred.weight", "module.1.crp_blocks.0.0.4_outvar_dimred.weight", "module.1.crp_blocks.1.0.1_outvar_dimred.weight", "module.1.crp_blocks.1.0.2_outvar_dimred.weight", "module.1.crp_blocks.1.0.3_outvar_dimred.weight", "module.1.crp_blocks.1.0.4_outvar_dimred.weight", "module.1.crp_blocks.2.0.1_outvar_dimred.weight", "module.1.crp_blocks.2.0.2_outvar_dimred.weight", "module.1.crp_blocks.2.0.3_outvar_dimred.weight", "module.1.crp_blocks.2.0.4_outvar_dimred.weight", "module.1.crp_blocks.3.0.1_outvar_dimred.weight", "module.1.crp_blocks.3.0.2_outvar_dimred.weight", "module.1.crp_blocks.3.0.3_outvar_dimred.weight", "module.1.crp_blocks.3.0.4_outvar_dimred.weight", "module.1.adapt_convs.0.weight", "module.1.adapt_convs.1.weight", "module.1.adapt_convs.2.weight", "module.1.heads.0.0.weight", "module.1.heads.0.2.weight", "module.1.heads.0.2.bias", "module.1.heads.1.0.weight", "module.1.heads.1.2.weight", "module.1.heads.1.2.bias".

I have tried replacing the module with "" as follows:

ckpt = torch.load('../../DenseTorch/ckpt/checkpoint.pth.tar')
pretrained_dict = ckpt['state_dict']
new_pretrained_dict = {key.replace("module.0.", ""): value for key, value in pretrained_dict.items()}
print("new state_dict keys: ", new_pretrained_dict.keys())
model.load_state_dict(new_pretrained_dict, strict=True)

but the error doesnt go away. Any suggestion on how to address this error?

Traceback (most recent call last):
  File "ExpNYUD_joint.py", line 48, in <module>
    model.load_state_dict(new_pretrained_dict, strict=True)
  File "/project/xfu/aamir/anaconda3/envs/MTLRefineNet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1483, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Net:
        Missing key(s) in state_dict: "conv8.weight", "conv7.weight", "conv6.weight", "conv5.weight", "conv4.weight", "conv3.weight", "crp4.0.1_outvar_dimred.weight", "crp4.0.2_outvar_dimred.weight", "crp4.0.3_outvar_dimred.weight", "crp4.0.4_outvar_dimred.weight", "crp3.0.1_outvar_dimred.weight", "crp3.0.2_outvar_dimred.weight", "crp3.0.3_outvar_dimred.weight", "crp3.0.4_outvar_dimred.weight", "crp2.0.1_outvar_dimred.weight", "crp2.0.2_outvar_dimred.weight", "crp2.0.3_outvar_dimred.weight", "crp2.0.4_outvar_dimred.weight", "crp1.0.1_outvar_dimred.weight", "crp1.0.2_outvar_dimred.weight", "crp1.0.3_outvar_dimred.weight", "crp1.0.4_outvar_dimred.weight", "conv_adapt4.weight", "conv_adapt3.weight", "conv_adapt2.weight", "pre_depth.weight", "depth.weight", "depth.bias", "pre_segm.weight", "segm.weight", "segm.bias".
        Unexpected key(s) in state_dict: "stem_convs.0.weight", "stem_convs.1.weight", "stem_convs.2.weight", "stem_convs.3.weight", "stem_convs.4.weight", "stem_convs.5.weight", "crp_blocks.0.0.1_outvar_dimred.weight", "crp_blocks.0.0.2_outvar_dimred.weight", "crp_blocks.0.0.3_outvar_dimred.weight", "crp_blocks.0.0.4_outvar_dimred.weight", "crp_blocks.1.0.1_outvar_dimred.weight", "crp_blocks.1.0.2_outvar_dimred.weight", "crp_blocks.1.0.3_outvar_dimred.weight", "crp_blocks.1.0.4_outvar_dimred.weight", "crp_blocks.2.0.1_outvar_dimred.weight", "crp_blocks.2.0.2_outvar_dimred.weight", "crp_blocks.2.0.3_outvar_dimred.weight", "crp_blocks.2.0.4_outvar_dimred.weight", "crp_blocks.3.0.1_outvar_dimred.weight", "crp_blocks.3.0.2_outvar_dimred.weight", "crp_blocks.3.0.3_outvar_dimred.weight", "crp_blocks.3.0.4_outvar_dimred.weight", "adapt_convs.0.weight", "adapt_convs.1.weight", "adapt_convs.2.weight", "heads.0.0.weight", "heads.0.2.weight", "heads.0.2.bias", "heads.1.0.weight", "heads.1.2.weight", "heads.1.2.bias".

Using strict=False does make the code run without errors, but the prediction is incorrect and the predictions do not show anything at the output images

shahaamirbader commented 2 years ago

Okay, so I did manage to resolve the error by replacing all the dictionary values as follows:

ckpt = torch.load('../../DenseTorch/ckpt/checkpoint.pth.tar')
pretrained_dict = ckpt['state_dict']
new_pretrained_dict = {key.replace("module.0.", ""): value for key, value in pretrained_dict.items()}
new_pretrained_dict = {key.replace("module.1.", ""): value for key, value in new_pretrained_dict.items()}
new_pretrained_dict = {key.replace("stem_convs.0", "conv8"): value for key, value in new_pretrained_dict.items()}
new_pretrained_dict = {key.replace("stem_convs.1", "conv7"): value for key, value in new_pretrained_dict.items()}
new_pretrained_dict = {key.replace("stem_convs.2", "conv6"): value for key, value in new_pretrained_dict.items()}
new_pretrained_dict = {key.replace("stem_convs.3", "conv5"): value for key, value in new_pretrained_dict.items()}
new_pretrained_dict = {key.replace("stem_convs.4", "conv4"): value for key, value in new_pretrained_dict.items()}
new_pretrained_dict = {key.replace("stem_convs.5", "conv3"): value for key, value in new_pretrained_dict.items()}
new_pretrained_dict = {key.replace("crp_blocks.0", "crp4"): value for key, value in new_pretrained_dict.items()}
new_pretrained_dict = {key.replace("crp_blocks.1", "crp3"): value for key, value in new_pretrained_dict.items()}
new_pretrained_dict = {key.replace("crp_blocks.2", "crp2"): value for key, value in new_pretrained_dict.items()}
new_pretrained_dict = {key.replace("crp_blocks.3", "crp1"): value for key, value in new_pretrained_dict.items()}
new_pretrained_dict = {key.replace("adapt_convs.0", "conv_adapt4"): value for key, value in new_pretrained_dict.items()}
new_pretrained_dict = {key.replace("adapt_convs.1", "conv_adapt3"): value for key, value in new_pretrained_dict.items()}
new_pretrained_dict = {key.replace("adapt_convs.2", "conv_adapt2"): value for key, value in new_pretrained_dict.items()}
new_pretrained_dict = {key.replace("heads.0.0", "pre_depth"): value for key, value in new_pretrained_dict.items()}
new_pretrained_dict = {key.replace("heads.0.2", "segm"): value for key, value in new_pretrained_dict.items()}
new_pretrained_dict = {key.replace("heads.1.0", "pre_segm"): value for key, value in new_pretrained_dict.items()}
new_pretrained_dict = {key.replace("heads.1.2", "depth"): value for key, value in new_pretrained_dict.items()}
#print("new state_dict keys: ", new_pretrained_dict.keys())
#model.load_state_dict(ckpt['state_dict'], strict=True)
model.load_state_dict(new_pretrained_dict)

but the output segmentation mask is not as accurate as authors provided pretrained model. image

Dheeru66k commented 1 year ago

Hi, i was reading your documentation here https://github.com/DrSleep/DenseTorch/blob/dev/docs/Models.md, where it is mentioned that you have to used return and combine layers as return_idx = [1, 2, 3, 4, 5, 6] combine_layers = [[0, 1], [2, 3], 4, 5]

If we use Mobilenet+MTLWRefienet, what to use if i train a single heads seperately, i mean if i want to train depth head alone, what "return_idx" and "combine_layers" to use, and similarly to "segm" and "normals"