joeyan / gaussian_splatting Goto Github PK
View Code? Open in Web Editor NEWUnofficial implementation of 3D Gaussian Splatting in PyTorch + CUDA with MIT license
License: MIT License
Unofficial implementation of 3D Gaussian Splatting in PyTorch + CUDA with MIT license
License: MIT License
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
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.
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];
}
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.