4
0
mirror of https://github.com/nerfstudio-project/nerfstudio.git synced 2026-11-11 02:24:38 +08:00

Fix IndexError runtime error (#1057)

* Fix IndexError runtime error

fixes this error:

  File "C:\code\nerfstudio\nerfstudio\data\dataparsers\nerfstudio_dataparser.py", line 232, in _generate_dataparser_outputs
    distortion_params = torch.stack(distort, dim=0)[idx_tensor]
IndexError: tensors used as indices must be long, byte or bool tensors

* Update nerfstudio_dataparser.py

Per discussion at https://github.com/nerfstudio-project/nerfstudio/pull/1057#issuecomment-1332670064
This commit is contained in:
machenmusik 2022-11-30 18:50:48 -05:00 committed by GitHub
parent 4f1319fde4
commit 533abb7d2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -212,7 +212,7 @@ class Nerfstudio(DataParser):
else:
camera_type = CameraType.PERSPECTIVE
idx_tensor = torch.tensor(indices)
idx_tensor = torch.tensor(indices, dtype=torch.long)
fx = float(meta["fl_x"]) if fx_fixed else torch.tensor(fx, dtype=torch.float32)[idx_tensor]
fy = float(meta["fl_y"]) if fy_fixed else torch.tensor(fy, dtype=torch.float32)[idx_tensor]
cx = float(meta["cx"]) if cx_fixed else torch.tensor(cx, dtype=torch.float32)[idx_tensor]