Florian-Barthel / splatviz

Full python interactive 3D Gaussian Splatting viewer for real-time editing and analyzing.
MIT License
1.18k stars 79 forks source link

GaussianModel.load_ply seems to only manage max_sh=0 or 3 degree #40

Closed JulienStanguennec-Leddartech closed 3 months ago

JulienStanguennec-Leddartech commented 3 months ago

Hi @Florian-Barthel ,

Thanks a lot for the great work, I was trying to use this viewer with ply file trained with sh degree=1, but was not able to.

Looking at the load_ply method of GaussianModel class, it seems that the max sh_degree managed is either 0 or 3. https://github.com/Florian-Barthel/splatviz/blob/main/gaussian-splatting/scene/gaussian_model.py#L275

        if len(extra_f_names) == 0:
            self.max_sh_degree = 0
        if len(extra_f_names) == 45:
            self.max_sh_degree = 3
        assert len(extra_f_names)==3*(self.max_sh_degree + 1) ** 2 - 3

When doing this change, it rendered:

        if len(extra_f_names) == 0:
            self.max_sh_degree = 0
        if len(extra_f_names) == 9:
            self.max_sh_degree = 1
        if len(extra_f_names) == 45:
            self.max_sh_degree = 3

Maybe it'd be added to the load function ?

Florian-Barthel commented 3 months ago

Hi, yes it seems like a good idea to add this. Probably it also makes sense to add a case for sh == 2, like:

if len(extra_f_names) == 0:
    self.max_sh_degree = 0
if len(extra_f_names) == 9:
    self.max_sh_degree = 1
if len(extra_f_names) == 24:
    self.max_sh_degree = 2
if len(extra_f_names) == 45:
    self.max_sh_degree = 3

I will add it tomorrow. You can also do a PR if want.

JulienStanguennec-Leddartech commented 3 months ago

Thanks for taking this into account :), I am a bit late for any PR ..