Skip to content

Commit 510e2a3

Browse files
author
Jianbo Ye
committed
use ply_color_mode
1 parent 9b3e3d7 commit 510e2a3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

nerfstudio/scripts/exporter.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ class ExportGaussianSplat(Exporter):
485485
"""Rotation of the oriented bounding box. Expressed as RPY Euler angles in radians"""
486486
obb_scale: Optional[Tuple[float, float, float]] = None
487487
"""Scale of the oriented bounding box along each axis."""
488-
use_sh0_renderer: bool = False
488+
ply_color_mode: Literal["sh_coeffs", "rbg"] = "sh_coeffs"
489489
"""If True, outputs for rendering in renderers that support SH0 rendering."""
490490

491491
@staticmethod
@@ -573,23 +573,23 @@ def main(self) -> None:
573573
for i in range(shs_0.shape[1]):
574574
map_to_tensors[f"f_dc_{i}"] = shs_0[:, i, None]
575575

576-
if self.use_sh0_renderer:
576+
if self.ply_color_mode == "rgb":
577577
CONSOLE.print(
578-
"Warning: trained model has higher level of spherical harmonics, option use_sh0_renderer is ignored."
578+
"Warning: model has higher level of spherical harmonics, option ply_color_mode is ignored."
579579
)
580580
# transpose(1, 2) was needed to match the sh order in Inria version
581581
shs_rest = model.shs_rest.transpose(1, 2).contiguous().cpu().numpy()
582582
shs_rest = shs_rest.reshape((n, -1))
583583
for i in range(shs_rest.shape[-1]):
584584
map_to_tensors[f"f_rest_{i}"] = shs_rest[:, i, None]
585585
else:
586-
if self.use_sh0_renderer:
586+
if self.ply_color_mode == "sh_coeffs":
587587
shs_0 = model.shs_0.contiguous().cpu().numpy()
588588
for i in range(shs_0.shape[1]):
589589
map_to_tensors[f"f_dc_{i}"] = RGB2SH(
590590
torch.clamp(model.colors.clone(), 0.0, 1.0).data.cpu().numpy()
591591
)[:, i]
592-
else:
592+
elif self.ply_color_mode == "rgb":
593593
colors = torch.clamp(model.colors.clone(), 0.0, 1.0).data.cpu().numpy()
594594
colors = (colors * 255).astype(np.uint8)
595595
map_to_tensors["red"] = colors[:, 0]

0 commit comments

Comments
 (0)