kwea123 / nerf_pl

NeRF (Neural Radiance Fields) and NeRF in the Wild using pytorch-lightning
https://www.youtube.com/playlist?list=PLDV2CyUo4q-K02pNEyDr7DYpTQuka3mbV
MIT License
2.74k stars 483 forks source link

Can't extract mesh #114

Closed WXuanyang closed 2 years ago

WXuanyang commented 2 years ago

I tried to extract the mesh with the ipynb code, but have the following bug in the third block (search for tight bound of the object)


RuntimeError Traceback (most recent call last)

in 24 dir_embedded = embedding_dir(dir_[i:i+chunk]) # (N, embed_dir_channels) 25 xyzdir_embedded = torch.cat([xyz_embedded, dir_embedded], 1) ---> 26 out_chunks += [nerf_fine(xyzdir_embedded)] 27 rgbsigma = torch.cat(out_chunks, 0) 28 ~/anaconda3/envs/nerf_pl/lib/python3.6/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs) 1100 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks 1101 or _global_forward_hooks or _global_forward_pre_hooks): -> 1102 return forward_call(*input, **kwargs) 1103 # Do not call functions when jit is used 1104 full_backward_hooks, non_full_backward_hooks = [], [] ~/mesh/nerf_pl/models/nerf.py in forward(self, x, sigma_only) 98 if not sigma_only: 99 input_xyz, input_dir = \ --> 100 torch.split(x, [self.in_channels_xyz, self.in_channels_dir], dim=-1) 101 else: 102 input_xyz = x ~/anaconda3/envs/nerf_pl/lib/python3.6/site-packages/torch/functional.py in split(tensor, split_size_or_sections, dim) 154 # split_size_or_sections. The branching code is in _tensor.py, which we 155 # call here. --> 156 return tensor.split(split_size_or_sections, dim) 157 158 ~/anaconda3/envs/nerf_pl/lib/python3.6/site-packages/torch/_tensor.py in split(self, split_size, dim) 516 return super(Tensor, self).split_with_sizes(split_size, dim) 517 else: --> 518 return super(Tensor, self).split_with_sizes(split_size, dim) 519 520 def unique(self, sorted=True, return_inverse=False, return_counts=False, dim=None): RuntimeError: start (0) + length (63) exceeds dimension size (42). I'm using the dev branch and trained with 4 1080ti gpu, is that a multi-gpu related problem?
WXuanyang commented 2 years ago

Oh I checked the file and I found the problem:

embedding_xyz = Embedding(10) embedding_dir = Embedding(4)

I changed those 2 lines in the second block and its now stop giving errors

kwea123 commented 2 years ago

Yes, I made an update recently, but forgot to update the .ipynb. For those who encounter the same error, please made the modification like above. I will correct this soon.