From 8c75a90f56f14f3af619d4061525dfdb3182ae64 Mon Sep 17 00:00:00 2001 From: Pythonix Huang <370048201@qq.com> Date: Thu, 27 Jul 2023 16:49:45 +0800 Subject: [PATCH] Add sort to ensure right order of properties read from ply file --- scene/gaussian_model.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scene/gaussian_model.py b/scene/gaussian_model.py index 9111d67..632a1e8 100644 --- a/scene/gaussian_model.py +++ b/scene/gaussian_model.py @@ -226,6 +226,7 @@ class GaussianModel: features_dc[:, 2, 0] = np.asarray(plydata.elements[0]["f_dc_2"]) extra_f_names = [p.name for p in plydata.elements[0].properties if p.name.startswith("f_rest_")] + extra_f_names = sorted(extra_f_names, key = lambda x: int(x.split('_')[-1])) assert len(extra_f_names)==3*(self.max_sh_degree + 1) ** 2 - 3 features_extra = np.zeros((xyz.shape[0], len(extra_f_names))) for idx, attr_name in enumerate(extra_f_names): @@ -234,11 +235,13 @@ class GaussianModel: features_extra = features_extra.reshape((features_extra.shape[0], 3, (self.max_sh_degree + 1) ** 2 - 1)) scale_names = [p.name for p in plydata.elements[0].properties if p.name.startswith("scale_")] + scale_names = sorted(scale_names, key = lambda x: int(x.split('_')[-1])) scales = np.zeros((xyz.shape[0], len(scale_names))) for idx, attr_name in enumerate(scale_names): scales[:, idx] = np.asarray(plydata.elements[0][attr_name]) rot_names = [p.name for p in plydata.elements[0].properties if p.name.startswith("rot")] + rot_names = sorted(rot_names, key = lambda x: int(x.split('_')[-1])) rots = np.zeros((xyz.shape[0], len(rot_names))) for idx, attr_name in enumerate(rot_names): rots[:, idx] = np.asarray(plydata.elements[0][attr_name])