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.07k stars 145 forks source link

Test_shape failed with torchsparse 1.2 #25

Closed YoushaaMurhij closed 2 years ago

YoushaaMurhij commented 2 years ago

Good work! I manged to get the shape using Test_shape.py but when using test_shape.py, I faced this error:

root@PC:/home/adelai_ws/AdelaiDepth# python3 LeReS/tools/test_shape.py --load_ckpt res101.pth --backbone resnext101
No protocol specified
processing (0000)-th image... LeReS/test_images/5.jpg
Traceback (most recent call last):
  File "LeReS/tools/test_shape.py", line 123, in <module>
    shift, focal_length, depth_scaleinv = reconstruct3D_from_depth(rgb, pred_depth_ori,
  File "LeReS/tools/test_shape.py", line 76, in reconstruct3D_from_depth
    shift_1 = refine_shift(pred_depth_norm, shift_model, predicted_focal_1, cam_u0, cam_v0)
  File "/home/adelai_ws/AdelaiDepth/LeReS/lib/test_utils.py", line 124, in refine_shift
    shift = refine_shift_one_step(depth_wshift_tmp, model, focal, u0, v0)
  File "/home/adelai_ws/AdelaiDepth/LeReS/lib/test_utils.py", line 108, in refine_shift_one_step
    outputs = model(inputs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/trainer/adelai_ws/AdelaiDepth/LeReS/lib/spvcnn_classsification.py", line 148, in forward
    x2 = self.stage2(x1)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/container.py", line 141, in forward
    input = module(input)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/trainer/adelai_ws/AdelaiDepth/LeReS/lib/spvcnn_classsification.py", line 23, in forward
    out = self.net(x)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/container.py", line 141, in forward
    input = module(input)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torchsparse/nn/modules/conv.py", line 72, in forward
    return conv3d(inputs,
  File "/usr/local/lib/python3.8/dist-packages/torchsparse/nn/functional/conv.py", line 118, in conv3d
    idx_query = list(convert_neighbor_map_gpu(idx_query))
  File "/usr/local/lib/python3.8/dist-packages/torchsparse/nn/functional/convert_neighbor_map.py", line 9, in forward
    idx_batch, idx_point = torch.where(neighbor_map != -1)
ValueError: not enough values to unpack (expected 2, got 1)

I tried another version (1.4) but there is a change in the API. Any suggestions? Thanks!

srikanth-midde commented 2 years ago

Hi, Can any help me to sort out this issue? I got the same "ValueError: not enough values to unpack (expected 2, got 1)" error. Though I tried with both torchsparse v1.2 and v1.4. but facing the same issue.

isamabdullah88 commented 2 years ago

Hey you can replace first line with second line with torchsparse==1.4 Replace this: from torchsparse.utils import sparse_collate_fn, sparse_quantize with this: from torchsparse.utils.collate import sparse_collate_fn from torchsparse.utils.quantize import sparse_quantize

It'll work with torchsparse==1.4

isamabdullah88 commented 2 years ago

Hey, Please check for default values for models in the test_shape.py and test_depth.py scripts. Those values are different (resnet50 and resnet101), and they have to be the same.

Ir1d commented 2 years ago

@isamabdullah88 What do you mean by default values? the values are the same @YoushaaMurhij Can you please share how you solved this?

isamabdullah88 commented 2 years ago

@Ir1d

Hope this helps!