GithubHelp home page GithubHelp logo

joeyan / gaussian_splatting Goto Github PK

View Code? Open in Web Editor NEW
89.0 89.0 4.0 210 KB

Unofficial implementation of 3D Gaussian Splatting in PyTorch + CUDA with MIT license

License: MIT License

Python 41.57% Cuda 39.14% C++ 1.64% Jupyter Notebook 17.36% Shell 0.29%
3d-reconstruction gaussian-splatting novel-view-synthesis

gaussian_splatting's People

Contributors

joeyan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gaussian_splatting's Issues

negative value for gaussian.rgb

Hi,
Thanks you very much for your very clean coding work.
I am using your code for training some scenes. some of the scenes looks fine, but others just totally fails. I checked the saved final gaussians. gaussian.rgb have negative values, its range is not within 0-1 or 0-255. I borrowed come code to save it as ply file and tried also convert gaussian.rgb to sperical harmonics dc by rgb/C0 + 0.5, which doesn't give the correct color when display ply with some open source gaussian splatting viewer.
Here is the code for saving gaussian to ply. The gaussians when rendered with viewer looks pale.

import os
from os import makedirs
from plyfile import PlyData, PlyElement
def construct_list_of_attributes(_features_dc, _features_rest, _scaling, _rotation):
l = ['x', 'y', 'z', 'nx', 'ny', 'nz']
# All channels except the 3 DC
for i in range(features_dc.shape[1]):
l.append('f_dc
{}'.format(i))
for i in range(features_rest.shape[1]):
l.append('f_rest
{}'.format(i))
l.append('opacity')
for i in range(scaling.shape[1]):
l.append('scale
{}'.format(i))
for i in range(rotation.shape[1]):
l.append('rot
{}'.format(i))
return l
def save_ply(path, gaussian):
makedirs(os.path.dirname(path), exist_ok= True)
xyz = gaussian.xyz.detach().cpu().numpy()
normals = np.zeros_like(xyz)
rgb = gaussian.rgb.detach().cpu().numpy() # * 0.28209479177387814 + 0.5
sh = gaussian.sh.detach().flatten(start_dim=1).contiguous().cpu().numpy()
opacities = gaussian.opacity.detach().cpu().numpy()
scale = gaussian.scale.detach().cpu().numpy()
rotation = gaussian.quaternion.detach().cpu().numpy()
dtype_full = [(attribute, 'f4') for attribute in construct_list_of_attributes(rgb,sh, scale, rotation)]
elements = np.empty(xyz.shape[0], dtype=dtype_full)
attributes = np.concatenate((xyz, normals, rgb, sh, opacities, scale, rotation), axis=1)
elements[:] = list(map(tuple, attributes))
el = PlyElement.describe(elements, 'vertex')
PlyData([el]).write(path)

the gaussian splatting viewer I am using is https://github.com/limacv/GaussianSplattingViewer

The following is one of the results
iter29999_test_image_8
We got reasonably good result for this scene by official gaussian splatting.
If you want the data to have a test. I could send it you.

Tests in test_rasterize_autograd run on "empty" images

All the gradient checks for rasterizer run in float64, which produces empty images for all values. This means that the gradient checks always pass regardless of changes to cuda code.

This is caused by the second term of the following if in render.cu (line 145):
if (alpha < 0.00392156862 || !use_fast_exp)
I believe it should instead be
if (alpha < 0.00392156862 && use_fast_exp)
so that the gaussians are not skipped for float64.

To prevent this in the future, I'd recommend adding a check in test_rasterize_autograd for whether the image is empty or not.

Also, could you share why the 0.25 is not added to the diagonal for float64 here?

if (use_fast_exp) {
  a = _conic[i * 3 + 0] + 0.25;
  c = _conic[i * 3 + 2] + 0.25;
} else {
  a = _conic[i * 3 + 0];
  c = _conic[i * 3 + 2];
}

All Gaussians Removed

Hi there, Thanks for a very clean code!

I try to build the code on my dataset. But In adaptive control step, Most of Gaussians are deleted
image

Could you suggest some directions?
Thank you

pip install -e ./ fails due to missing torch dependency

Running pip install -e ./ fails due to ModuleNotFoundError: No module named 'torch' but running python setup.py build_ext && python setup.py install works. It seems like this is a similar issue to this issue in flash-attention. It might be due to a version mismatch in python/PyTorch/CUDA.

Full error output:

  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> [19 lines of output]
      Traceback (most recent call last):
        File "/home/joe/.pyenv/versions/3.9.18/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/joe/.pyenv/versions/3.9.18/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/joe/.pyenv/versions/3.9.18/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 132, in get_requires_for_build_editable
          return hook(config_settings)
        File "/tmp/pip-build-env-t_928sd7/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 448, in get_requires_for_build_editable
          return self.get_requires_for_build_wheel(config_settings)
        File "/tmp/pip-build-env-t_928sd7/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-t_928sd7/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-t_928sd7/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 487, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-t_928sd7/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 2, in <module>
      ModuleNotFoundError: No module named 'torch'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.