-
Notifications
You must be signed in to change notification settings - Fork 15
Description
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.