@@ -485,7 +485,7 @@ class ExportGaussianSplat(Exporter):
485
485
"""Rotation of the oriented bounding box. Expressed as RPY Euler angles in radians"""
486
486
obb_scale : Optional [Tuple [float , float , float ]] = None
487
487
"""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"
489
489
"""If True, outputs for rendering in renderers that support SH0 rendering."""
490
490
491
491
@staticmethod
@@ -573,23 +573,23 @@ def main(self) -> None:
573
573
for i in range (shs_0 .shape [1 ]):
574
574
map_to_tensors [f"f_dc_{ i } " ] = shs_0 [:, i , None ]
575
575
576
- if self .use_sh0_renderer :
576
+ if self .ply_color_mode == "rgb" :
577
577
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."
579
579
)
580
580
# transpose(1, 2) was needed to match the sh order in Inria version
581
581
shs_rest = model .shs_rest .transpose (1 , 2 ).contiguous ().cpu ().numpy ()
582
582
shs_rest = shs_rest .reshape ((n , - 1 ))
583
583
for i in range (shs_rest .shape [- 1 ]):
584
584
map_to_tensors [f"f_rest_{ i } " ] = shs_rest [:, i , None ]
585
585
else :
586
- if self .use_sh0_renderer :
586
+ if self .ply_color_mode == "sh_coeffs" :
587
587
shs_0 = model .shs_0 .contiguous ().cpu ().numpy ()
588
588
for i in range (shs_0 .shape [1 ]):
589
589
map_to_tensors [f"f_dc_{ i } " ] = RGB2SH (
590
590
torch .clamp (model .colors .clone (), 0.0 , 1.0 ).data .cpu ().numpy ()
591
591
)[:, i ]
592
- else :
592
+ elif self . ply_color_mode == "rgb" :
593
593
colors = torch .clamp (model .colors .clone (), 0.0 , 1.0 ).data .cpu ().numpy ()
594
594
colors = (colors * 255 ).astype (np .uint8 )
595
595
map_to_tensors ["red" ] = colors [:, 0 ]
0 commit comments