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

KeyError: 'model_state_dict' #58

Closed 283pm closed 1 year ago

283pm commented 1 year ago

Thanks for the great repository. I ran the Train.sh file for fine tuning with the original data from the res50.pth file and got the following error. How can I solve this error?

Thank you

Traceback (most recent call last): File "../tools/train.py", line 290, in main() File "../tools/train.py", line 286, in main main_worker(0, ngpus_per_node, train_args, val_args) File "../tools/train.py", line 221, in main_worker load_ckpt(train_args, model, optimizer.optimizer, scheduler, val_err) File "/home/robotics/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'

yohannes-taye commented 1 year ago

Hi @283pm, did you try replacing the 'model_state_dict' with 'depth_model'?

283pm commented 1 year ago

Yes, I did.

If I replace "model_state_dict" with "depth_model", I got the following error.

RuntimeError: Error(s) in loading state_dict for RelDepthModel: Missing key(s) in state_dict: "depth_model.encoder_modules.encoder.conv1.weight", --- many weights and biases --- "depth_model.auxi_modules.out_conv.adapt_conv.3.bias". Unexpected key(s) in state_dict: "shift_model", "focal_model".

yohannes-taye commented 1 year ago

@283pm I have made some modifications in a new fork. Give it a try to see if it can work for you.

283pm commented 1 year ago

Your modifications solved my problem. Thank you.