Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion threedgrut/export/scripts/ply_to_usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ def main():
logger.info(f"Successfully exported to {output_path}")
except Exception as e:
logger.error(f"Error processing PLY file: {e}")
import traceback
logger.error(f"Full traceback: {traceback.format_exc()}")
sys.exit(1)


if __name__ == "__main__":
main()
main()
22 changes: 16 additions & 6 deletions threedgrut/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,12 +685,22 @@ def init_from_ply(self, mogt_path:str, init_model=True):
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]))
num_speculars = (self.max_n_features + 1) ** 2 - 1
assert len(extra_f_names)==3*num_speculars
mogt_specular = np.zeros((num_gaussians, len(extra_f_names)))
for idx, attr_name in enumerate(extra_f_names):
mogt_specular[:, idx] = np.asarray(plydata.elements[0][attr_name])
mogt_specular = mogt_specular.reshape((num_gaussians,3,num_speculars))
mogt_specular = mogt_specular.transpose(0, 2, 1).reshape((num_gaussians,num_speculars*3))
expected_extra_f_count = 3 * num_speculars

if len(extra_f_names) == expected_extra_f_count:
# Full spherical harmonics data available
mogt_specular = np.zeros((num_gaussians, len(extra_f_names)))
for idx, attr_name in enumerate(extra_f_names):
mogt_specular[:, idx] = np.asarray(plydata.elements[0][attr_name])
mogt_specular = mogt_specular.reshape((num_gaussians,3,num_speculars))
mogt_specular = mogt_specular.transpose(0, 2, 1).reshape((num_gaussians,num_speculars*3))
elif len(extra_f_names) == 0:
# Only DC components available, create zero-filled higher-order harmonics
logger.info(f"PLY file only contains DC components, initializing higher-order spherical harmonics to zero")
mogt_specular = np.zeros((num_gaussians, num_speculars * 3))
else:
# Partial data - this is unexpected
raise ValueError(f"Unexpected number of f_rest_ properties: found {len(extra_f_names)}, expected {expected_extra_f_count} or 0")

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]))
Expand Down