brandleyzhou / DIFFNet

[BMVC 2021] ''Self-Supervised Monocular Depth Estimation with Internal Feature Fusion''
109 stars 21 forks source link

Missing Keys in 1024x320 Pretrained Weights #28

Closed turi-mate closed 1 year ago

turi-mate commented 1 year ago

Hi @brandleyzhou! Thank you for your work!

I met a problem when testing your pretrained models:

RuntimeError: Error(s) in loading state_dict for HRDepthDecoder:
       Missing key(s) in state_dict: "convs.72.ca.fc.0.weight", "convs.72.ca.fc.2.weight", "convs.72.conv_se.weight", "convs.72.conv_se.bias", "convs.36.ca.fc.0.weight", "convs.36.ca.fc.2.weight", "convs.36.conv_se.weight", "convs.36.conv_se.bias", "convs.18.ca.fc.0.weight", "convs.18.ca.fc.2.weight", "convs.18.conv_se.weight", "convs.18.conv_se.bias", "convs.9.ca.fc.0.weight", "convs.9.ca.fc.2.weight", "convs.9.conv_se.weight", "convs.9.conv_se.bias", "decoder.2.ca.fc.0.weight", "decoder.2.ca.fc.2.weight", "decoder.3.ca.fc.0.weight", "decoder.3.ca.fc.2.weight", "decoder.4.ca.fc.0.weight", "decoder.4.ca.fc.2.weight", "decoder.5.ca.fc.0.weight", "decoder.5.ca.fc.2.weight".
       Unexpected key(s) in state_dict: "convs.72fSE.fc.0.weight", "convs.72fSE.fc.2.weight", "convs.72fSE.conv_se.weight", "convs.72fSE.conv_se.bias", "convs.36fSE.fc.0.weight", "convs.36fSE.fc.2.weight", "convs.36fSE.conv_se.weight", "convs.36fSE.conv_se.bias", "convs.18fSE.fc.0.weight", "convs.18fSE.fc.2.weight", "convs.18fSE.conv_se.weight", "convs.18fSE.conv_se.bias", "convs.9fSE.fc.0.weight", "convs.9fSE.fc.2.weight", "convs.9fSE.conv_se.weight", "convs.9fSE.conv_se.bias", "decoder.2.fc.0.weight", "decoder.2.fc.2.weight", "decoder.3.fc.0.weight", "decoder.3.fc.2.weight", "decoder.4.fc.0.weight", "decoder.4.fc.2.weight", "decoder.5.fc.0.weight", "decoder.5.fc.2.weight".

The pretrained weights are downloaded from this repository, I was testing 4 models:

I only experienced the problem with the 1024x320 model. Could you please have a look at what the problem might be? Thanks in advance!

brandleyzhou commented 1 year ago

Hi. In fact, they are not missing, and they are given different names(unexpected keys) when initializing depth net. It is because 1024x320 was trained with an older version HRDepthDecoder. Only these key/ module names matter, the values (models' weights) will not be impacted. So you can simply map these keys to new keys. e.g. change key name "convs.72fSE.fc.0.weight" to "convs.72.ca.fc.0.weight" before loading state_dict onto model.

I hope my answer can solve your confusion.

turi-mate commented 1 year ago

Hi, thanks for the quick reply and clarification! Maybe you could put this into README?