aim-uofa / AdelaiDepth

This repo contains the projects: 'Virtual Normal', 'DiverseDepth', and '3D Scene Shape'. They aim to solve the monocular depth estimation, 3D scene reconstruction from single image problems.
Creative Commons Zero v1.0 Universal
1.06k stars 144 forks source link

Error Loading a custom trained model or resume training from a check point. #44

Closed abhineet-pandey closed 2 years ago

abhineet-pandey commented 2 years ago

File "/mnt/disk/code/AdelaiDepth/LeReS/Train/lib/utils/net_tools.py", line 44, in load_ckpt
checkpoint_state_dict_noprefix = strip_prefix_if_present(checkpoint['model_state_dict'], "module.") KeyError: 'model_state_dict'

With resuming training from a checkpoint or loading a self trained model.

Similar KeyError when loading a demo trained model in the Minist_test script (test_depth.py or test_shape.py)

To reproduce this error just train the demo model (..Train/scripts/train_demo.py) and try loading using the inference code in the Minist_test.

Please let me know if you need more details. Any help would be much appreciated

guangkaixu commented 2 years ago

@abhineet-pandey Hi, if you would like to load the self-trained model and do inference, you can: https://github.com/aim-uofa/AdelaiDepth/blob/c5370f150c10fd17761c835fca9b5956c3bff9fe/LeReS/Minist_Test/lib/net_tools.py#L40 modify checkpoint['depth_model'] to checkpoint['model_state_dict'] and ensure strict=False (or remove the weights of depth_model.auxi_modules).

Resuming training from a self-trained model weight seems to contain no bugs for me. Thanks for your following and please comment casually if you still suffer from some problems.

abhineet-pandey commented 2 years ago

Thanks a lots.

777-en commented 1 year ago

@abhineet-pandey Hi, if you would like to load the self-trained model and do inference, you can:

https://github.com/aim-uofa/AdelaiDepth/blob/c5370f150c10fd17761c835fca9b5956c3bff9fe/LeReS/Minist_Test/lib/net_tools.py#L40

modify checkpoint['depth_model'] to checkpoint['model_state_dict'] and ensure strict=False (or remove the weights of depth_model.auxi_modules). Resuming training from a self-trained model weight seems to contain no bugs for me. Thanks for your following and please comment casually if you still suffer from some problems.

Hi! Thank you for your gorgeous work. I met the same problem. Could you explain more about "ensure strict=False (or remove the weights of depth_model.auxi_modules)", what exactly should I do? @guangkaixu @abhineet-pandey