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

Add depth visualization #30

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

ingra14m
Copy link

No description provided.

@grgkopanas
Copy link
Collaborator

this seems to depend on this:
#20 ?

@ingra14m
Copy link
Author

This is depend on the graphdeco-inria/diff-gaussian-rasterization#3

@JIANG-CX
Copy link

JIANG-CX commented Aug 8, 2023

May I confirm if the current branch does not include the capability to render depth?

@ingra14m
Copy link
Author

The render part can be seen in #5 in diff-gaussian-rasterization

@JIANG-CX
Copy link

The render part can be seen in #5 in diff-gaussian-rasterization

Thanks for your reply. I have read your proposed code modification, which involves changing the alpha-blending process from ∑Tαc to ∑Tαd. However, I have noticed that there are instances where there are only a few points with a large covariance on a uniformly colored floor or wall. It is possible that using this method in such areas could result in significant errors.

@ingra14m
Copy link
Author

There are indeed many artifacts in the depth maps of 3D-GS. I tried to improve the geometry of 3D-GS by adding depth loss in #5 in diff-gaussian-rasterization, which might enhance the rendering effects of 3D-GS. However, experimental results show that improving the geometry does not substantially improve the rendering quality. I personally believe that the depth issues of 3D-GS are inevitable.

@Bin-ze
Copy link

Bin-ze commented Sep 13, 2023

@ingra14m Thank you very much for your implementation of depth forward and direction, but when I pull your code and then try to do depth supervision, a memory leak occurs at a random step of the training iteration:

Training progress:   4%|█████▏                                                                                                                                 | 1140/30000 [00:27<11:08, 43.16it/s, Loss=0.1069719]
  Traceback (most recent call last):
    File "train.py", line 301, in <module>
      training(lp.extract(args), op.extract(args), pp.extract(args), args.test_iterations, args.save_iterations, args.checkpoint_iterations, args.start_checkpoint, args.debug_from, args.depth_loss_choice)
    File "train.py", line 131, in training
      ema_loss_for_log = 0.4 * loss.item() + 0.6 * ema_loss_for_log
  RuntimeError: CUDA error: an illegal memory access was encountered
  CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
  For debugging consider passing CUDA_LAUNCH_BLOCKING=1.

What can be determined is that the error has nothing to do with the location where the error is reported:

ema_loss_for_log = 0.4 * loss.item() + 0.6 * ema_loss_for_log

When using the original rasterizer implementation, this does not exist. so the problem is in the depth gradient calculation part of your implementation, I don't know what's going on, are you facing a similar problem again?

@Bin-ze
Copy link

Bin-ze commented Sep 13, 2023

There are indeed many artifacts in the depth maps of 3D-GS. I tried to improve the geometry of 3D-GS by adding depth loss in #5 in diff-gaussian-rasterization, which might enhance the rendering effects of 3D-GS. However, experimental results show that improving the geometry does not substantially improve the rendering quality. I personally believe that the depth issues of 3D-GS are inevitable.

Replenish:

 python -m torch.utils.collect_env
Collecting environment information...
PyTorch version: 1.12.1
Is debug build: False
CUDA used to build PyTorch: 11.6
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.5 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Clang version: Could not collect
CMake version: version 3.22.0
Libc version: glibc-2.17

Python version: 3.7.13 (default, Oct 18 2022, 18:57:03)  [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-69-generic-x86_64-with-debian-bullseye-sid
Is CUDA available: True
CUDA runtime version: Could not collect
GPU models and configuration: 
GPU 0: NVIDIA GeForce RTX 4090
GPU 1: NVIDIA GeForce RTX 4090

Nvidia driver version: 525.105.17
cuDNN version: Probably one of the following:
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.7.0
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.21.5
[pip3] torch==1.12.1
[pip3] torchaudio==0.12.1
[pip3] torchvision==0.13.1
[conda] blas                      1.0                         mkl  
[conda] cudatoolkit               11.6.2              hfc3e2af_12    conda-forge
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
[conda] mkl                       2021.4.0           h8d4b97c_729    conda-forge
[conda] mkl-service               2.4.0            py37h402132d_0    conda-forge
[conda] mkl_fft                   1.3.1            py37h3e078e5_1    conda-forge
[conda] mkl_random                1.2.2            py37h219a48f_0    conda-forge
[conda] numpy                     1.21.5                   pypi_0    pypi
[conda] pytorch                   1.12.1          py3.7_cuda11.6_cudnn8.3.2_0    pytorch
[conda] pytorch-mutex             1.0                        cuda    pytorch
[conda] torchaudio                0.12.1               py37_cu116    pytorch
[conda] torchvision               0.13.1               py37_cu116    pytorch

error:

File "train.py", line 137, in training
    loss.backward()
  File "/home/miniconda3/envs/3d_gaussian_depth/lib/python3.7/site-packages/torch/_tensor.py", line 396, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
  File "/home/miniconda3/envs/3d_gaussian_depth/lib/python3.7/site-packages/torch/autograd/__init__.py", line 175, in backward
    allow_unreachable=True, accumulate_grad=True)  # Calls into the C++ engine to run the backward pass
RuntimeError: CUDA error: an illegal memory access was encountered
Training progress:   2%|█▌                                                                          | 610/30000 [00:03<02:35, 189.05it/s, Loss=0.5014731]

@ingra14m
Copy link
Author

There are indeed many artifacts in the depth maps of 3D-GS. I tried to improve the geometry of 3D-GS by adding depth loss in #5 in diff-gaussian-rasterization, which might enhance the rendering effects of 3D-GS. However, experimental results show that improving the geometry does not substantially improve the rendering quality. I personally believe that the depth issues of 3D-GS are inevitable.

Replenish:

 python -m torch.utils.collect_env
Collecting environment information...
PyTorch version: 1.12.1
Is debug build: False
CUDA used to build PyTorch: 11.6
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.5 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Clang version: Could not collect
CMake version: version 3.22.0
Libc version: glibc-2.17

Python version: 3.7.13 (default, Oct 18 2022, 18:57:03)  [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-69-generic-x86_64-with-debian-bullseye-sid
Is CUDA available: True
CUDA runtime version: Could not collect
GPU models and configuration: 
GPU 0: NVIDIA GeForce RTX 4090
GPU 1: NVIDIA GeForce RTX 4090

Nvidia driver version: 525.105.17
cuDNN version: Probably one of the following:
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.7.0
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.21.5
[pip3] torch==1.12.1
[pip3] torchaudio==0.12.1
[pip3] torchvision==0.13.1
[conda] blas                      1.0                         mkl  
[conda] cudatoolkit               11.6.2              hfc3e2af_12    conda-forge
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
[conda] mkl                       2021.4.0           h8d4b97c_729    conda-forge
[conda] mkl-service               2.4.0            py37h402132d_0    conda-forge
[conda] mkl_fft                   1.3.1            py37h3e078e5_1    conda-forge
[conda] mkl_random                1.2.2            py37h219a48f_0    conda-forge
[conda] numpy                     1.21.5                   pypi_0    pypi
[conda] pytorch                   1.12.1          py3.7_cuda11.6_cudnn8.3.2_0    pytorch
[conda] pytorch-mutex             1.0                        cuda    pytorch
[conda] torchaudio                0.12.1               py37_cu116    pytorch
[conda] torchvision               0.13.1               py37_cu116    pytorch

error:

File "train.py", line 137, in training
    loss.backward()
  File "/home/miniconda3/envs/3d_gaussian_depth/lib/python3.7/site-packages/torch/_tensor.py", line 396, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
  File "/home/miniconda3/envs/3d_gaussian_depth/lib/python3.7/site-packages/torch/autograd/__init__.py", line 175, in backward
    allow_unreachable=True, accumulate_grad=True)  # Calls into the C++ engine to run the backward pass
RuntimeError: CUDA error: an illegal memory access was encountered
Training progress:   2%|█▌                                                                          | 610/30000 [00:03<02:35, 189.05it/s, Loss=0.5014731]

That problem was fixed in the latest version of diff-gaussian-rasterization. If you want to visualize the depth in the forward pass, you can refer to my another branch latest and reset to commit with the comment "Add depth forward pass" in the following picture. The latest commit of that branch containing visualization of the acc and depth.
image

@Bin-ze
Copy link

Bin-ze commented Sep 14, 2023

There are indeed many artifacts in the depth maps of 3D-GS. I tried to improve the geometry of 3D-GS by adding depth loss in #5 in diff-gaussian-rasterization, which might enhance the rendering effects of 3D-GS. However, experimental results show that improving the geometry does not substantially improve the rendering quality. I personally believe that the depth issues of 3D-GS are inevitable.

Replenish:

 python -m torch.utils.collect_env
Collecting environment information...
PyTorch version: 1.12.1
Is debug build: False
CUDA used to build PyTorch: 11.6
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.5 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Clang version: Could not collect
CMake version: version 3.22.0
Libc version: glibc-2.17

Python version: 3.7.13 (default, Oct 18 2022, 18:57:03)  [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-69-generic-x86_64-with-debian-bullseye-sid
Is CUDA available: True
CUDA runtime version: Could not collect
GPU models and configuration: 
GPU 0: NVIDIA GeForce RTX 4090
GPU 1: NVIDIA GeForce RTX 4090

Nvidia driver version: 525.105.17
cuDNN version: Probably one of the following:
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.7.0
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.21.5
[pip3] torch==1.12.1
[pip3] torchaudio==0.12.1
[pip3] torchvision==0.13.1
[conda] blas                      1.0                         mkl  
[conda] cudatoolkit               11.6.2              hfc3e2af_12    conda-forge
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
[conda] mkl                       2021.4.0           h8d4b97c_729    conda-forge
[conda] mkl-service               2.4.0            py37h402132d_0    conda-forge
[conda] mkl_fft                   1.3.1            py37h3e078e5_1    conda-forge
[conda] mkl_random                1.2.2            py37h219a48f_0    conda-forge
[conda] numpy                     1.21.5                   pypi_0    pypi
[conda] pytorch                   1.12.1          py3.7_cuda11.6_cudnn8.3.2_0    pytorch
[conda] pytorch-mutex             1.0                        cuda    pytorch
[conda] torchaudio                0.12.1               py37_cu116    pytorch
[conda] torchvision               0.13.1               py37_cu116    pytorch

error:

File "train.py", line 137, in training
    loss.backward()
  File "/home/miniconda3/envs/3d_gaussian_depth/lib/python3.7/site-packages/torch/_tensor.py", line 396, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
  File "/home/miniconda3/envs/3d_gaussian_depth/lib/python3.7/site-packages/torch/autograd/__init__.py", line 175, in backward
    allow_unreachable=True, accumulate_grad=True)  # Calls into the C++ engine to run the backward pass
RuntimeError: CUDA error: an illegal memory access was encountered
Training progress:   2%|█▌                                                                          | 610/30000 [00:03<02:35, 189.05it/s, Loss=0.5014731]

That problem was fixed in the latest version of diff-gaussian-rasterization. If you want to visualize the depth in the forward pass, you can refer to my another branch latest and reset to commit with the comment "Add depth forward pass" in the following picture. The latest commit of that branch containing visualization of the acc and depth. image

Thank you for your response! , I tried pulling the latest latest branch:

git checkout latest
Then re-run the training but get an error:

Training progress: 0%| | 0/30000 [00:00<?, ?it/s]
Traceback (most recent call last):
File "train.py", line 304, in
training(lp.extract(args), op.extract(args), pp.extract(args), args.test_iterations, args.save_iterations, args.checkpoint_iterations, args.start_checkpoint, args.debug_from, args.depth_loss_choice)
File "train.py", line 92, in training
render_pkg = render(viewpoint_cam, gaussians, pipe, background)
File "/home/guozebin/work_code/3d_gaussian_magic_change/gaussian_renderer/init.py", line 266, in render
cov3D_precomp=cov3D_precomp)
ValueError: too many values to unpack (expected 3)
Training progress: 0%|

Your implementation also seems to conflict with the official implementation of 3D-GS on the output of the rasterizer. Can you tell me how to solve it?

@ingra14m
Copy link
Author

There are indeed many artifacts in the depth maps of 3D-GS. I tried to improve the geometry of 3D-GS by adding depth loss in #5 in diff-gaussian-rasterization, which might enhance the rendering effects of 3D-GS. However, experimental results show that improving the geometry does not substantially improve the rendering quality. I personally believe that the depth issues of 3D-GS are inevitable.

Replenish:

 python -m torch.utils.collect_env
Collecting environment information...
PyTorch version: 1.12.1
Is debug build: False
CUDA used to build PyTorch: 11.6
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.5 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Clang version: Could not collect
CMake version: version 3.22.0
Libc version: glibc-2.17

Python version: 3.7.13 (default, Oct 18 2022, 18:57:03)  [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-69-generic-x86_64-with-debian-bullseye-sid
Is CUDA available: True
CUDA runtime version: Could not collect
GPU models and configuration: 
GPU 0: NVIDIA GeForce RTX 4090
GPU 1: NVIDIA GeForce RTX 4090

Nvidia driver version: 525.105.17
cuDNN version: Probably one of the following:
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.7.0
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.21.5
[pip3] torch==1.12.1
[pip3] torchaudio==0.12.1
[pip3] torchvision==0.13.1
[conda] blas                      1.0                         mkl  
[conda] cudatoolkit               11.6.2              hfc3e2af_12    conda-forge
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
[conda] mkl                       2021.4.0           h8d4b97c_729    conda-forge
[conda] mkl-service               2.4.0            py37h402132d_0    conda-forge
[conda] mkl_fft                   1.3.1            py37h3e078e5_1    conda-forge
[conda] mkl_random                1.2.2            py37h219a48f_0    conda-forge
[conda] numpy                     1.21.5                   pypi_0    pypi
[conda] pytorch                   1.12.1          py3.7_cuda11.6_cudnn8.3.2_0    pytorch
[conda] pytorch-mutex             1.0                        cuda    pytorch
[conda] torchaudio                0.12.1               py37_cu116    pytorch
[conda] torchvision               0.13.1               py37_cu116    pytorch

error:

File "train.py", line 137, in training
    loss.backward()
  File "/home/miniconda3/envs/3d_gaussian_depth/lib/python3.7/site-packages/torch/_tensor.py", line 396, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
  File "/home/miniconda3/envs/3d_gaussian_depth/lib/python3.7/site-packages/torch/autograd/__init__.py", line 175, in backward
    allow_unreachable=True, accumulate_grad=True)  # Calls into the C++ engine to run the backward pass
RuntimeError: CUDA error: an illegal memory access was encountered
Training progress:   2%|█▌                                                                          | 610/30000 [00:03<02:35, 189.05it/s, Loss=0.5014731]

That problem was fixed in the latest version of diff-gaussian-rasterization. If you want to visualize the depth in the forward pass, you can refer to my another branch latest and reset to commit with the comment "Add depth forward pass" in the following picture. The latest commit of that branch containing visualization of the acc and depth. image

Thank you for your response! , I tried pulling the latest latest branch:

git checkout latest
Then re-run the training but get an error:

Training progress: 0%| | 0/30000 [00:00<?, ?it/s] Traceback (most recent call last): File "train.py", line 304, in training(lp.extract(args), op.extract(args), pp.extract(args), args.test_iterations, args.save_iterations, args.checkpoint_iterations, args.start_checkpoint, args.debug_from, args.depth_loss_choice) File "train.py", line 92, in training render_pkg = render(viewpoint_cam, gaussians, pipe, background) File "/home/guozebin/work_code/3d_gaussian_magic_change/gaussian_renderer/init.py", line 266, in render cov3D_precomp=cov3D_precomp) ValueError: too many values to unpack (expected 3) Training progress: 0%|

Your implementation also seems to conflict with the official implementation of 3D-GS on the output of the rasterizer. Can you tell me how to solve it?

You can git reset --hard 4a3f789 to the commit that only has the forward depth pass.

@guanjunwu
Copy link

guanjunwu commented Sep 14, 2023

when I was running depth supervision on your modified code, I also faced a similar problem about Ilegeal memory was encountered.

It seems like the problem in the code is the depths computation of const float c_d = collected_depths[j]; in cuda_rasterizer/backward.cu. And when querying the array collected_depths at some iterations after, the error occurred. I also noticed that you have set the c_d = 1 when performing backpropagation. But I don't know why the error happened. Is there any effective solution to that problem?

@Bin-ze
Copy link

Bin-ze commented Sep 15, 2023

There are indeed many artifacts in the depth maps of 3D-GS. I tried to improve the geometry of 3D-GS by adding depth loss in #5 in diff-gaussian-rasterization, which might enhance the rendering effects of 3D-GS. However, experimental results show that improving the geometry does not substantially improve the rendering quality. I personally believe that the depth issues of 3D-GS are inevitable.

Replenish:

 python -m torch.utils.collect_env
Collecting environment information...
PyTorch version: 1.12.1
Is debug build: False
CUDA used to build PyTorch: 11.6
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.5 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Clang version: Could not collect
CMake version: version 3.22.0
Libc version: glibc-2.17

Python version: 3.7.13 (default, Oct 18 2022, 18:57:03)  [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-69-generic-x86_64-with-debian-bullseye-sid
Is CUDA available: True
CUDA runtime version: Could not collect
GPU models and configuration: 
GPU 0: NVIDIA GeForce RTX 4090
GPU 1: NVIDIA GeForce RTX 4090

Nvidia driver version: 525.105.17
cuDNN version: Probably one of the following:
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.7.0
/usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.7.0
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.21.5
[pip3] torch==1.12.1
[pip3] torchaudio==0.12.1
[pip3] torchvision==0.13.1
[conda] blas                      1.0                         mkl  
[conda] cudatoolkit               11.6.2              hfc3e2af_12    conda-forge
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
[conda] mkl                       2021.4.0           h8d4b97c_729    conda-forge
[conda] mkl-service               2.4.0            py37h402132d_0    conda-forge
[conda] mkl_fft                   1.3.1            py37h3e078e5_1    conda-forge
[conda] mkl_random                1.2.2            py37h219a48f_0    conda-forge
[conda] numpy                     1.21.5                   pypi_0    pypi
[conda] pytorch                   1.12.1          py3.7_cuda11.6_cudnn8.3.2_0    pytorch
[conda] pytorch-mutex             1.0                        cuda    pytorch
[conda] torchaudio                0.12.1               py37_cu116    pytorch
[conda] torchvision               0.13.1               py37_cu116    pytorch

error:

File "train.py", line 137, in training
    loss.backward()
  File "/home/miniconda3/envs/3d_gaussian_depth/lib/python3.7/site-packages/torch/_tensor.py", line 396, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
  File "/home/miniconda3/envs/3d_gaussian_depth/lib/python3.7/site-packages/torch/autograd/__init__.py", line 175, in backward
    allow_unreachable=True, accumulate_grad=True)  # Calls into the C++ engine to run the backward pass
RuntimeError: CUDA error: an illegal memory access was encountered
Training progress:   2%|█▌                                                                          | 610/30000 [00:03<02:35, 189.05it/s, Loss=0.5014731]

That problem was fixed in the latest version of diff-gaussian-rasterization. If you want to visualize the depth in the forward pass, you can refer to my another branch latest and reset to commit with the comment "Add depth forward pass" in the following picture. The latest commit of that branch containing visualization of the acc and depth. image

Thank you for your response! , I tried pulling the latest latest branch:

git checkout latest
Then re-run the training but get an error:

Training progress: 0%| | 0/30000 [00:00<?, ?it/s] Traceback (most recent call last): File "train.py", line 304, in training(lp.extract(args), op.extract(args), pp.extract(args), args.test_iterations, args.save_iterations, args.checkpoint_iterations, args.start_checkpoint, args.debug_from, args.depth_loss_choice) File "train.py", line 92, in training render_pkg = render(viewpoint_cam, gaussians, pipe, background) File "/home/guozebin/work_code/3d_gaussian_magic_change/gaussian_renderer/init.py", line 266, in render cov3D_precomp=cov3D_precomp) ValueError: too many values to unpack (expected 3) Training progress: 0%|
Your implementation also seems to conflict with the official implementation of 3D-GS on the output of the rasterizer. Can you tell me how to solve it?

You can git reset --hard 4a3f789 to the commit that only has the forward depth pass.

Thanks for your reply, but I want to back-transmit the depth gradient for depth supervision, so can you tell me how you solved the memory leak problem to get the results after depth supervision?

when I using latest branch and change rasteriser return: rendered_image, radii, depth, acc, Training begins,but the same error occurred:

  RuntimeError: CUDA error: an illegal memory access was encountered
  CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
  For debugging consider passing CUDA_LAUNCH_BLOCKING=1

There is a memory leak in the calculation of DL_Ddepth but I can't solve it, can you give me some helpful suggestions?

@ingra14m
Copy link
Author

calculation

This problem is solved by official diff-gaussian-rasterization. The 'latest' branch is build on the latest official diff-gaussian-rasterization. The latest commit of the latest added acc visualization. So if you want to back-transmit the depth gradient for depth supervision, there are two choices:

  1. git reset --hard d26ea87
  2. no git reset and add another variable to receive acc. For example,
rendered_image, radii, depth, acc = rasterizer(
        means3D = means3D,
        means2D = means2D,
        shs = shs,
        colors_precomp = colors_precomp,
        opacities = opacity,
        scales = scales,
        rotations = rotations,
        cov3D_precomp = cov3D_precomp)

@ingra14m
Copy link
Author

performing

I think this memory problem is solved by official 3D GS. You can refer to my another branch, this branch build upon the latest diff-gaussian-rasterization. Since I add acc visualization, you can git reset --hard d26ea87 to the commit that only contains forward and backward depth pass.

@Bin-ze
Copy link

Bin-ze commented Sep 15, 2023

I used the second solution when the problem mentioned above occurred, and the memory leak problem was still visible in my experiments.
step:

  1. clon code : git clone [email protected]:ingra14m/diff-gaussian-rasterization.git
  2. checkout latest branch: git checkout latest
  3. make: pip install -v -e .
  4. add another variable to receive acc like you
  5. train
    but error occurred:

RuntimeError: CUDA error: an illegal memory access was encountered
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1

@ingra14m
Copy link
Author

I recommend you to reset, because the recent commits related to acc have not been strictly checked.

@Bin-ze
Copy link

Bin-ze commented Sep 15, 2023

I recommend you to reset, because the recent commits related to acc have not been strictly checked.

Frustrating that it still happens after a reset, what should I do?

@Bin-ze
Copy link

Bin-ze commented Sep 22, 2023

@ingra14m Sorry to bother you!
Is there any progress on this issue?

@ingra14m
Copy link
Author

sorry for late reply. Could you provide me with the dataset you used?

@VladimirYugay
Copy link

@ingra14m can't provide the dataset, but exact same error happens to me as well. Will attaching snapshots help?

@ingra14m
Copy link
Author

It would be definitely great if you could provide a snapshots of the errors.

@Bin-ze
Copy link

Bin-ze commented Sep 25, 2023

@ingra14m can't provide the dataset, but exact same error happens to me as well. Will attaching snapshots help?

Thank you very much for your reply! In my test, all data sets will have memory leakage errors. My depth comes from the monocular depth estimation algorithm. I have tried a lot of data sets, including mipinerf-360 scenarios. I will upload the dpeth of the data set to the cloud disk tomorrow. I am looking forward to your experimental results.! Thank you again!

On the other hand, I got a snapshot of the error and turned it on. He checked the output and input, but no abnormality was found.

@Bin-ze
Copy link

Bin-ze commented Sep 26, 2023

sorry for late reply. Could you provide me with the dataset you used?

Here is a very simple custom scene I made and used to test deep supervision:
https://drive.google.com/file/d/1Gwny9MawwzZ4PutD3I0ANolW89Et1Dxs/view?usp=sharing

@ingra14m
Copy link
Author

got it. I'll check it right away

@ingra14m
Copy link
Author

ingra14m commented Sep 26, 2023

sorry for late reply. Could you provide me with the dataset you used?

Here is a very simple custom scene I made and used to test deep supervision: https://drive.google.com/file/d/1Gwny9MawwzZ4PutD3I0ANolW89Et1Dxs/view?usp=sharing

Thank you for your patience. I have completed the testing of your data. Fortunately, your data can be executed on my end, and the rendering results with depth are evidently much superior to those without depth. Here is my core code:

depth = render_pkg_re["depth"]

# Just make the depth_gt and the gaussian depth with the same dimension
depth_image = depth_image.reshape(1, 1, *depth_image.shape)
depth_gt = F.interpolate(fid, size=(900, 1600), mode='bilinear', align_corners=False)[0]  # match the scaling process of official 3D Gaussian

depth_gt = depth_gt / depth_gt.max()  # make the depth_gt ranging from 0-1
loss = (1.0 - opt.lambda_dssim) * Ll1 + opt.lambda_dssim * (1.0 - ssim(image, gt_image)) + l1_loss(depth_gt, depth) * 0.1

As for the Differential Gaussian Rasterization, I did as I said before (I have made a depth branch):

git clone https://github.com/ingra14m/diff-gaussian-rasterization
cd diff-gaussian-rasterization
git checkout depth
pip install .

Here is the results from me:

I read the data as colmap format, and no --eval. It seems that there are 6 training images

with depth supervision
image
The mean PSNR of training dataset is 40.29. The training time is 23min35s on Tesla V100.

without depth supervision
image
The mean PSNR of training dataset is 33.16. The training time is 23min33s.

@ingra14m
Copy link
Author

ingra14m commented Sep 26, 2023

I didn't do anything special. I just read the corresponding depth in your depth directory. I think if there's anything I can call special, it's probably my depth normalization depth_gt = depth_gt / depth_gt.max() # make the depth_gt ranging from 0-1. My machine's operating system is Ubuntu 20.04 & Debian with Tesla V100. It can be run on both machines.
As for the Differential Gaussian Rasterization, I reconfigured the environment and I can confirm that this is the final version of my depth branch

@Bin-ze
Copy link

Bin-ze commented Sep 26, 2023

I quickly tried it, but as always, I couldn't perform the full training anyway, and the error kept appearing randomly in the middle of the training:

RuntimeError: CUDA error: an illegal memory access was encountered
Training progress: 8%|███████████████████▊ | 2530/30000 [01:17<14:06, 32.45it/s, Loss=0.2167022]

I thought I might have missed some key step, but I did install the rasterizer as you asked:
git clone https://github.com/ingra14m/diff-gaussian-rasterization.git
git checkout depth
pip install .

then:

CUDA_VISIBLE_DEVICES=2 python train.py -s data/test_depth_super -r 4

I did some more tests, and I found that if the gap between gt and pred is very large when calculating loss, corresponding to the situation where gt is not processed, a memory leak will quickly occur, so I think the problem is gradient explosion. caused. In the case of inputting real gt, this problem does not exist, because after normalization, the difference between the two is very small.
Thank you very much for your reply. Now I realize that it is not a problem with your implementation, but is it possible to clamp the return gradient to ensure that it is limited to a reasonable range and avoid outliers caused by inaccurate deep supervision?

@ricshaw
Copy link

ricshaw commented Sep 26, 2023

Cloning from the original 3DGS repo and doing:
git clone https://github.com/ingra14m/diff-gaussian-rasterization
cd diff-gaussian-rasterization
git checkout depth
pip install .

I get the same error:

File "train.py", line 96, in training
ema_loss_for_log = 0.4 * loss.item() + 0.6 * ema_loss_for_log
RuntimeError: CUDA error: an illegal memory access was encountered
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.

@Zzh2000
Copy link

Zzh2000 commented Sep 26, 2023

Hi @ingra14m, I also changed the branch to "depth" and reinstalled it through pip.
I am running using the dataset provided by Bin-ze, but still have the illegal memory access problem, even without adding the depth loss to the total loss for backward (e.g. only using rgb L1 loss):

Traceback (most recent call last):
File "train.py", line 284, in
training(lp.extract(args), op.extract(args), pp.extract(args), args.test_iterations, args.save_iterations, args.checkpoint_iterations, args.start_checkpoint, args.debug_from)
File "train.py", line 158, in training
loss.backward()
File "/cluster/project/infk/cvg/zihzhu/miniconda3/envs/gaussian_splatting/lib/python3.7/site-packages/torch/_tensor.py", line 396, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
File "/cluster/project/infk/cvg/zihzhu/miniconda3/envs/gaussian_splatting/lib/python3.7/site-packages/torch/autograd/init.py", line 175, in backward
allow_unreachable=True, accumulate_grad=True) # Calls into the C++ engine to run the backward pass
RuntimeError: CUDA error: an illegal memory access was encountered
Training progress: 2%|▏ | 650/30000 [00:23<17:58, 27.21it/s, Loss=0.0562482,

I am also using V100, would it be possible for you to directly zip the whole "gaussian-splatting" folder that can run this dataset for me to double-check?
Thanks in advance!

@Bin-ze
Copy link

Bin-ze commented Sep 27, 2023

I didn't do anything special. I just read the corresponding depth in your depth directory. I think if there's anything I can call special, it's probably my depth normalization depth_gt = depth_gt / depth_gt.max() # make the depth_gt ranging from 0-1. My machine's operating system is Ubuntu 20.04 & Debian with Tesla V100. It can be run on both machines. As for the Differential Gaussian Rasterization, I reconfigured the environment and I can confirm that this is the final version of my depth branch

I think if you don't convert pred_depth to disparity map to calculate the loss, then the algorithm will diverge quickly and should not get good results but should be completely unoptimizable, so I'm confused about the results you got, you can share the checkpoints with me ?

@ingra14m
Copy link
Author

I must sincerely apologize, as I have to admit that I made a mistake. In your dataset, I used the wrong environment. The results I obtained were actually using the main branch of diff-gaussian-rasterization, a branch that only has a forward pass for depth and lacks a backward pass. Theoretically, adding depth loss in this environment should have no impact on the results, as there are no depth-related gradients affecting the parameters of 3D Gaussians through backpropagation, but the experimental results indeed show an impact. After using the depth branch, I encountered the same illegal memory access error on your dataset. This is a situation I have never encountered before. In my experiments today, the HyperNeRF dataset and my custom Lego dataset can run normally, but errors occur with the Tensor4D and your dataset. I speculate that it might be due to the lesser number of viewpoints; otherwise, this is for a reason unknown to me. You can find my modifications in my commit, which theoretically should not produce illegal access issues.

@Bin-ze
Copy link

Bin-ze commented Sep 27, 2023

I must sincerely apologize, as I have to admit that I made a mistake. In your dataset, I used the wrong environment. The results I obtained were actually using the main branch of diff-gaussian-rasterization, a branch that only has a forward pass for depth and lacks a backward pass. Theoretically, adding depth loss in this environment should have no impact on the results, as there are no depth-related gradients affecting the parameters of 3D Gaussians through backpropagation, but the experimental results indeed show an impact. After using the depth branch, I encountered the same illegal memory access error on your dataset. This is a situation I have never encountered before. In my experiments today, the HyperNeRF dataset and my custom Lego dataset can run normally, but errors occur with the Tensor4D and your dataset. I speculate that it might be due to the lesser number of viewpoints; otherwise, this is for a reason unknown to me. You can find my modifications in my commit, which theoretically should not produce illegal access issues.

Thank you very much for your reply, I think the error is not due to too few views.
After my experiments, using this PR did not work on any of my datasets even without adding a deep supervised loss (i.e. without using backpropagated gradients), including of course the custom colmap dataset and the mipnerf360 dataset.
In addition, the same is true after adding deep supervision loss, and the training cannot be completed. The error message has been mentioned many times in this issue.
I don’t know what happened, but I’m sure there must be something wrong when calculating the gradient. I lack experience in debugging CUDA, but I have made some attempts and communicated with other interested friends. Learned that when he commented out:

dL_dalpha += (c_d - accum_depth_rec) * dL_ddepthchannel;

The algorithm seems to no longer make errors in his environment, although it is completely impossible to obtain the correct gradient, which seems to confirm my above guess.
Thank you again for taking the time to answer my questions. Your PR is great, but it seems that there are still some things that need to be overcome. I look forward to your reply.

@ingra14m
Copy link
Author

Thank you for your interest in this work. Although there are some issues with it at present, rendering it inapplicable to all datasets with depth, I have some suggestions that might aid your subsequent endeavors.

  1. I believe that depth information does not significantly aid the convergence of 3D Gaussian. You can refer to my PR for this. Although the inclusion of depth loss has mitigated the artifacts in the depth information of vanilla 3D-GS, it has almost no impact on the PSNR of rendered RGB.

  2. I presume that the current 3D-GS cannot represent specular reflection; you can run it on Lego (provided by NeRF) to verify my statement. Therefore, I have increased the order of SH in the 4th-degree branch. Although there is a certain improvement reflected in PSNR, the specular reflection still do not appear, and moreover, the training speed has significantly slowed down.

I hope your research progresses smoothly, and should you require assistance, I will do my utmost to help.

@RaymondJiangkw
Copy link

RaymondJiangkw commented Sep 28, 2023

Hi, I encounterred a similar issue. After reading his implementation (thanks to that), I found somewhere to be interesting.

At here, the code style is python-like even though it should be cuda.

I think that depth assignment should be included in the if-statement, therefore I added a big parentheses to include both for-statement and that line. After recompiling, the error disappeared in my case. Hope my modification follows the original idea.

@ingra14m
Copy link
Author

Hi, I encounterred a similar issue. After reading his implementation (thanks to that), I found somewhere to be interesting.

At here, the code style is python-like even though it should be cuda.

I think that depth assignment should be included in the if-statement, therefore I added a big parentheses to include both for-statement and that line. After recompiling, the error disappeared in my case. Hope my modification follows the original idea.

Thank you very much for your discovery. It is evident that I employed Python styling in the code and overlooked the fact that this is CUDA code lol. I appreciate your identification of this issue; this bug has now been corrected. I wish you smooth progress in your research!

@VladimirYugay
Copy link

@ingra14m can you point out some derivation of the depth gradient computation?

@ingra14m
Copy link
Author

ingra14m commented Sep 30, 2023

@ingra14m can you point out some derivation of the depth gradient computation?

@VladimirYugay As illustrated in Equation (3) of the 3D-GS paper, the color for each pixel is
$$C=\sum_{i \in \mathcal{N}} c_{i} \alpha_{i} \prod_{j=1}^{i-1}\left(1-\alpha_{j}\right).$$ The computation of depth is analogous to that of color. In my forward pass, the depth is implemented as $$D=\sum_{i \in \mathcal{N}} z_{i} \alpha_{i} \prod_{j=1}^{i-1}\left(1-\alpha_{j}\right),$$ where $z_i$ is the z coordinate for each 3D Gaussian. Consequently, in the backward propagation, the calculation of the gradient of depth should be consistent with that of color. It only requires rewriting the computational process corresponding to color for depth.

@RaymondJiangkw
Copy link

@ingra14m can you point out some derivation of the depth gradient computation?

@VladimirYugay As illustrated in Equation (3) of the 3D-GS paper, the color for each pixel is C=∑i∈Nciαi∏j=1i−1(1−αj). The computation of depth is analogous to that of color. In my forward pass, the depth is implemented as D=∑i∈Nziαi∏j=1i−1(1−αj), where zi is the z coordinate for each 3D Gaussian. Consequently, in the backward propagation, the calculation of the gradient of depth should be consistent with that of color. It only requires rewriting the computational process corresponding to color for depth.

Hi,

I am not sure if it is correct. In your implementation, the depth is defined as the weighted aggregation of z-value in the camera space. But, in other nerf implementations, I think the depth is usually defined as the weighted aggregation of the length between the points on the ray and the origin of the ray?

@ingra14m
Copy link
Author

ingra14m commented Oct 3, 2023

@RaymondJiangkw Hi,
You're correct. Typically, the depth in NeRF is indeed represented as the length between the points on the ray and the origin of the ray. However, I believe that depth is an attribute that depicts relative spatial relationships, reflecting the accuracy of geometric reconstruction. Therefore, in tasks where depth supervision is not considered, using the z-coordinate in the camera space to represent depth, in my opinion, is acceptable.

@RaymondJiangkw
Copy link

@RaymondJiangkw Hi, You're correct. Typically, the depth in NeRF is indeed represented as the length between the points on the ray and the origin of the ray. However, I believe that depth is an attribute that depicts relative spatial relationships, reflecting the accuracy of geometric reconstruction. Therefore, in tasks where depth supervision is not considered, using the z-coordinate in the camera space to represent depth, in my opinion, is acceptable.

Thanks for your explanation. :)

@robot0321
Copy link

@ingra14m can you point out some derivation of the depth gradient computation?

@VladimirYugay As illustrated in Equation (3) of the 3D-GS paper, the color for each pixel is C=∑i∈Nciαi∏j=1i−1(1−αj). The computation of depth is analogous to that of color. In my forward pass, the depth is implemented as D=∑i∈Nziαi∏j=1i−1(1−αj), where zi is the z coordinate for each 3D Gaussian. Consequently, in the backward propagation, the calculation of the gradient of depth should be consistent with that of color. It only requires rewriting the computational process corresponding to color for depth.

Thank you for the interesting idea, but I'm not sure it is really acceptable.
If there is a single clear surface, you can use the corresponding coordinate with high alpha.
However, if there are multiple transparent surfaces, using this depth may cause an error.

@ingra14m
Copy link
Author

@ingra14m can you point out some derivation of the depth gradient computation?

@VladimirYugay As illustrated in Equation (3) of the 3D-GS paper, the color for each pixel is C=∑i∈Nciαi∏j=1i−1(1−αj). The computation of depth is analogous to that of color. In my forward pass, the depth is implemented as D=∑i∈Nziαi∏j=1i−1(1−αj), where zi is the z coordinate for each 3D Gaussian. Consequently, in the backward propagation, the calculation of the gradient of depth should be consistent with that of color. It only requires rewriting the computational process corresponding to color for depth.

Thank you for the interesting idea, but I'm not sure it is really acceptable. If there is a single clear surface, you can use the corresponding coordinate with high alpha. However, if there are multiple transparent surfaces, using this depth may cause an error.

Maybe you are right. This is the depth from drums in vanilla NeRF Dataset. But I'm not sure if the NeRF/Mip-NeRF can handle the depth of multiple transparent surfaces.
image

@XuHu0529
Copy link

@ingra14m Sorry to bother you. I try to render depth image using your given method. I use the followings:

git clone https://github.com/ingra14m/diff-gaussian-rasterization
cd diff-gaussian-rasterization
pip install .

I am in main branch, because I only want to get the rendered depth. But when I try pip install ., there is somthing wrong and I cannot install it. However, I didn't meet such error using the official codes. Could you please help me with it?
The error is somthing like:

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for diff-gaussian-rasterization
  Running setup.py clean for diff-gaussian-rasterization
Failed to build diff-gaussian-rasterization
ERROR: Could not build wheels for diff-gaussian-rasterization, which is required to install pyproject.toml-based projects

Thank you very much!!!

@robot0321
Copy link

robot0321 commented Oct 19, 2023

Maybe you are right. This is the depth from drums in vanilla NeRF Dataset. But I'm not sure if the NeRF/Mip-NeRF can handle the depth of multiple transparent surfaces.

A naive way to select the frontmost surface is to apply a low softmax temperature to alpha to weight.
As shown in the picture, you can make the large alpha large and the small alpha small (blue color) to select only one surface.
Note: alpha converted in this way should only be used when calculating depth.
Edit: I'm sorry but the method described above can also select the surface behind. It should be applied to alpha*T (=weight), not alpha.

image

@robot0321
Copy link

@ingra14m
Hi again,
I try to evaluate depth rendering strategies above and got the depth map from the renderer.
But for nerf_synthetic, I cannot compare the GT depth map and the rendered depth.
here suggests multiplying 8.0 to the normalized depth (.png file which is provided by NeRF authors) to get GT depth, but I'm not sure it is correct.
Sorry to bother you, but how do you get the GT depth map for nerf_synthetic for evaluation?

@ingra14m
Copy link
Author

@ingra14m Sorry to bother you. I try to render depth image using your given method. I use the followings:

git clone https://github.com/ingra14m/diff-gaussian-rasterization
cd diff-gaussian-rasterization
pip install .

I am in main branch, because I only want to get the rendered depth. But when I try pip install ., there is somthing wrong and I cannot install it. However, I didn't meet such error using the official codes. Could you please help me with it? The error is somthing like:

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for diff-gaussian-rasterization
  Running setup.py clean for diff-gaussian-rasterization
Failed to build diff-gaussian-rasterization
ERROR: Could not build wheels for diff-gaussian-rasterization, which is required to install pyproject.toml-based projects

Thank you very much!!!

hi, I think a possible reason is that the current URL of my repo is https://github.com/ingra14m/depth-diff-gaussian-rasterization. You may not have downloaded my repo completely.

@ingra14m
Copy link
Author

ingra14m commented Oct 20, 2023

@ingra14m Hi again, I try to evaluate depth rendering strategies above and got the depth map from the renderer. But for nerf_synthetic, I cannot compare the GT depth map and the rendered depth. here suggests multiplying 8.0 to the normalized depth (.png file which is provided by NeRF authors) to get GT depth, but I'm not sure it is correct. Sorry to bother you, but how do you get the GT depth map for nerf_synthetic for evaluation?

Hi @robot0321, because NeRF provides blender files, I directly used Blender's depth rendering engine to output the depth. I normalize this depth as GT. I've rendered the Lego and Hotdog with depth here if you need them.

@liorfritz
Copy link

@RaymondJiangkw Hi, You're correct. Typically, the depth in NeRF is indeed represented as the length between the points on the ray and the origin of the ray. However, I believe that depth is an attribute that depicts relative spatial relationships, reflecting the accuracy of geometric reconstruction. Therefore, in tasks where depth supervision is not considered, using the z-coordinate in the camera space to represent depth, in my opinion, is acceptable.

Could you please explain what is the difference between the distance of points on the ray to the camera origin and the z-coordinate in the camera space? Aren't they the same?

@JyVenom
Copy link

JyVenom commented Dec 4, 2023

@liorfritz

@RaymondJiangkw Hi, You're correct. Typically, the depth in NeRF is indeed represented as the length between the points on the ray and the origin of the ray. However, I believe that depth is an attribute that depicts relative spatial relationships, reflecting the accuracy of geometric reconstruction. Therefore, in tasks where depth supervision is not considered, using the z-coordinate in the camera space to represent depth, in my opinion, is acceptable.

Could you please explain what is the difference between the distance of points on the ray to the camera origin and the z-coordinate in the camera space? Aren't they the same?

If we simplify the situation down to 2d, with the ray shooting in the +x axis, the "distance of points on the ray to the camera origin" would be the hypotenuse, where as the "z-coordinate in the camera space" refers to the length of the x axis side.

                  . point
                 / |
  ray length->  /  |
camera origin ./___|
                   ^ z coordinate

so to convert depth to a 3d point, assuming we just shoot the ray out and do not account for camera rotation and translation:
if depth is length of ray, you use sin and cosine to find the x, y, AND z values of the point
if depth is the z-coordinate, you use sin and cosine to find the x and y ONLY. the z value is the depth.

I hope this makes sense.

@karaokenoway
Copy link

Hi,what a great job!
I don't know whether the depth image is related to sh attributes in rendering? There is sth wrong with my rendering depth image. @ingra14m

@JyVenom
Copy link

JyVenom commented Mar 27, 2024

Hi,what a great job! I don't know whether the depth image is related to sh attributes in rendering? There is sth wrong with my rendering depth image. @ingra14m

Hi, the depth is used to determine the order in which the splats are added up. The SH coefficients are used to get the directional color when rendering in cuda (by default, unless you pass in a color override from python).

Depth is for rendering order. Remember that the gaussians are first split into tiles, then in each tile they are added up by the C * alpha * T equation in order by increasing depth. This fork merely computes and returns the depth image with a very similar equation D * alpha * T.

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

Successfully merging this pull request may close these issues.

None yet