Skip to content

How to understand the empty normals saved? #210

@SleepTight-Cat

Description

@SleepTight-Cat

Hi authors,
I appreciate your work on 2D Gaussian Splatting—thank you for sharing it.
While reviewing the code, I came across a section in scene/gaussian_model.py that I found a bit unclear. Specifically, in the save_ply function:

def save_ply(self, path):
        mkdir_p(os.path.dirname(path))

        xyz = self._xyz.detach().cpu().numpy()
        normals = np.zeros_like(xyz)
        f_dc = self._features_dc.detach().transpose(1, 2).flatten(start_dim=1).contiguous().cpu().numpy()
        f_rest = self._features_rest.detach().transpose(1, 2).flatten(start_dim=1).contiguous().cpu().numpy()
        opacities = self._opacity.detach().cpu().numpy()
        scale = self._scaling.detach().cpu().numpy()
        rotation = self._rotation.detach().cpu().numpy()

        dtype_full = [(attribute, 'f4') for attribute in self.construct_list_of_attributes()]

        elements = np.empty(xyz.shape[0], dtype=dtype_full)
        attributes = np.concatenate((xyz, normals, f_dc, f_rest, opacities, scale, rotation), axis=1)
        elements[:] = list(map(tuple, attributes))
        el = PlyElement.describe(elements, 'vertex')
        PlyData([el]).write(path)

I noticed that the normals array is initialized as all zeros (np.zeros_like(xyz)) before being written to the PLY file. Could you clarify the reasoning behind this? Is this a placeholder for future normal calculations (which I didn't find where), or is there another purpose for saving zeroed normals?
I would greatly appreciate any insights you can provide.
Thanks in advance for your time!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions