TRI-ML / packnet-sfm

TRI-ML Monocular Depth Estimation Repository
https://tri-ml.github.io/packnet-sfm/
MIT License
1.24k stars 243 forks source link

inference example gives KeyError: 0 in docker #154

Closed mslavescu closed 3 years ago

mslavescu commented 3 years ago

Hi,

I tried to run in Docker the inference example, and I'm getting this error:

File "scripts/infer.py", line 87, in infer_and_save_depth pred_inv_depth = model_wrapper.depth(image)[0

Here are the commands to reproduce this behavior:

python3 scripts/infer.py --checkpoint /data/checkpoints/PackNet01_MR_semisup_CStoK.ckpt --input /data/datasets/KITTI_tiny 2011_09_26/2011_09_26_drive_0023_sync/image_02/data/ --output out/
### Preparing Model
Model: SemiSupModel
DepthNet: PackNet01
PoseNet: PoseNet
Found 7 files
Traceback (most recent call last):
  File "scripts/infer.py", line 160, in 
    main(args)
  File "scripts/infer.py", line 155, in main
    fn, args.output, model_wrapper, image_shape, args.half, args.save)
  File "/usr/local/lib/python3.6/dist-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "scripts/infer.py", line 87, in infer_and_save_depth
    pred_inv_depth = model_wrapper.depth(image)[0]
 KeyError: 0
VitorGuizilini-TRI commented 3 years ago

Can you try adding a ['inv_depths'] before the [0] to see if that fixes the issue?

mslavescu commented 3 years ago

Thanks! That did the trick, it works now. image

porwalnaman01 commented 3 years ago

@mslavescu Hello there, did you receive this error while training, if yes then how did you solve it?

Traceback (most recent call last): File "scripts/train.py", line 68, in train(args.file) File "scripts/train.py", line 63, in train trainer.fit(model_wrapper) File "/disk1/dan/Naman/packnet-sfm/packnet_sfm/trainers/horovod_trainer.py", line 65, in fit validation_output = self.validate(val_dataloaders, module) File "/disk1/dan/Naman/packnet-sfm/packnet_sfm/trainers/horovod_trainer.py", line 120, in validate output = module.validation_step(batch, i, n) File "/disk1/dan/Naman/packnet-sfm/packnet_sfm/models/model_wrapper.py", line 194, in validation_step output = self.evaluate_depth(batch) File "/disk1/dan/Naman/packnet-sfm/packnet_sfm/models/model_wrapper.py", line 302, in evaluate_depth inv_depths[0], inv_depths_flipped[0], method='mean') File "/disk1/dan/Naman/packnet-sfm/packnet_sfm/utils/depth.py", line 247, in post_process_inv_depth B,C, H, W = inv_depth.shape ValueError: not enough values to unpack (expected 4, got 3)

mslavescu commented 3 years ago

@porwalnaman01 my issue was during inferrence, see my steps above. @VitorGuizilini-TRI fixed it already, just pull latest code.

Your problem seems different, so it is better to open a separate issue.