Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: tensors used as indices must be long, byte or bool tensors #80

Open
kuaiqushangzixiba opened this issue Jan 8, 2024 · 2 comments

Comments

@kuaiqushangzixiba
Copy link

Number of gaussians left: 185091
Opacities min/max/mean: tensor(0.5000, device='cuda:0') tensor(1., device='cuda:0') tensor(0.9852, device='cuda:0')
Quantile 0.0: 0.5000418424606323
Quantile 0.1: 0.989769458770752
Quantile 0.2: 0.9993429780006409
Quantile 0.3: 0.99977046251297
Quantile 0.4: 0.9998769760131836
Quantile 0.5: 0.99992835521698
Quantile 0.6: 0.9999568462371826
Quantile 0.7: 0.9999749660491943
Quantile 0.8: 0.9999866485595703
Quantile 0.9: 0.9999943971633911
Traceback (most recent call last):
File "/data/SuGaR-main/train.py", line 141, in
coarse_mesh_path = extract_mesh_from_coarse_sugar(coarse_mesh_args)[0]
File "/data/SuGaR-main/sugar_extractors/coarse_mesh.py", line 209, in extract_mesh_from_coarse_sugar
mesh = sugar.mesh
File "/data/SuGaR-main/sugar_scene/sugar_model.py", line 497, in mesh
maps=SH2RGB(self.texture_features[..., 0, :][None]), #texture_img[None]),
File "/data/SuGaR-main/sugar_scene/sugar_model.py", line 492, in texture_features
return self.sh_coordinates[self.point_idx_per_pixel]
IndexError: tensors used as indices must be long, byte or bool tensors

@Anttwo
Copy link
Owner

Anttwo commented Jan 12, 2024

Hello @kuaiqushangzixiba,

May I ask more details about your error, and the commands you used?

Looking at your error, self.point_idx_per_pixel may be empty (maybe because of a None somewhere), which could produce your IndexError.
Maybe the foreground of your scene is empty, or something like that.

May I ask, what does your scene look like?

@sanosano
Copy link

@kuaiqushangzixiba

I encountered the same issue. However, in my case, self.point_idx_per_pixel was not empty.
The problem was resolved by changing self.sh_coordinates[self.point_idx_per_pixel] to self.sh_coordinates[self.point_idx_per_pixel.long()].

In sugar_model.py, self._surface_mesh_faces is also used as indices in 4 lines, for instance in:

faces_verts = self._points[self._surface_mesh_faces]  # n_faces, 3, n_coords

You should replace these with self._surface_mesh_faces.long().

@Anttwo
Thank you for your excellent work.
The issue may be related to the version of PyTorch being used.
In my case, I'm using PyTorch version 1.13.1+cu117.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants