idiap / ESLAM

Apache License 2.0
204 stars 21 forks source link

RuntimeError: cannot reshape tensor of 0 elements into shape [0, -1] #9

Closed DelinQu closed 1 year ago

DelinQu commented 1 year ago

H idiap,

Thanks for releasing your code, it really helps me. I'm testing your code on my own dataset, but caught the CUDA Memory Out error. So I follow this issue and change the meshing setting below:

meshing:
  level_set: 0
  resolution: 0.01 #cm # Increase this number to speed up meshing algorithm
  eval_rec: False
  mesh_bound_scale: 1.02

# change to:

meshing:
  level_set: 0
  resolution: 32 #cm # Increase this number to speed up meshing algorithm
  eval_rec: False
  mesh_bound_scale: 1.00

The Memory Out error disappears bug I got another problem:

Traceback (most recent call last):
  File "/home/yanchi/miniconda3/envs/eslam/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/home/yanchi/miniconda3/envs/eslam/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/home/yanchi/qudelin/ESLAM/src/ESLAM.py", line 259, in mapping
    self.mapper.run()
  File "/home/yanchi/qudelin/ESLAM/src/Mapper.py", line 473, in run
    self.mesher.get_mesh(mesh_out_file, all_planes, self.decoders, self.keyframe_dict, self.device)
  File "/home/yanchi/qudelin/ESLAM/src/utils/Mesher.py", line 234, in get_mesh
    for i, pnts in enumerate(torch.split(points, self.points_batch_size, dim=0)):
  File "/home/yanchi/qudelin/ESLAM/src/utils/Mesher.py", line 170, in eval_points
    ret = decoders(pi, all_planes=all_planes)
  File "/home/yanchi/miniconda3/envs/eslam/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/yanchi/qudelin/ESLAM/src/networks/decoders.py", line 165, in forward
    raw = raw.reshape(*p_shape[:-1], -1)
RuntimeError: cannot reshape tensor of 0 elements into shape [0, -1] because the unspecified dimension size -1 can be any value and is ambiguous

It seems that they decoder reshape an empty tensor of shape (0, 4) at the forward step.

I have no idea how to solve this problem, could you provide me something about the setting rule of mesh_bound_scale, resolution, and bound? BTW, would the 3D reconstruction evaluation stay safe if I do not render a 3D ply file?

I'm looking forward to your reply and thanks in advance.

MohammadJohari commented 1 year ago

Hello,

From the first glance, it seems like you have set the resolution too coarse.

You do not need to worry about the mesh_bound_scale. You need to set the bound correctly so that it encompasses your whole room size. Also, please note that you need to provide the model with the first-frame camera pose. It could be an arbitrary camera pose, but the scene bound should be enough to cover the scene w.r.t that arbitrary camera pose. You can then tune the resolution to not have an out of memory error for mesh extraction.

Lastly, the 3D reconstruction evaluation directly uses a 3D ply file. Unfortunately, you need to render that.

I hope this helps.