Skip to content

Rendering from intermediate Gaussians using sRGB fails #6

@NicoRumm

Description

@NicoRumm

The issue

Color space conversion from sRGB (Line 324) fails, because colors is expected to be a PyTorch tensor, but only converted later:

# Parse color space.
color_space_index = supplement_data.get("color_space", 1)
color_space = cs_utils.decode_color_space(color_space_index)
if color_space == "sRGB":
colors = cs_utils.sRGB2linearRGB(colors)
mean_vectors = torch.from_numpy(mean_vectors).view(1, -1, 3).float()
quaternions = torch.from_numpy(quaternions).view(1, -1, 4).float()
singular_values = torch.exp(torch.from_numpy(scale_logits).view(1, -1, 3)).float()
opacities = torch.sigmoid(torch.from_numpy(opacity_logits).view(1, -1)).float()
colors = torch.from_numpy(colors).view(1, -1, 3).float()

How it happened

Ran prediction using cpu, then called:

$ sharp render -i _workspace/gaussians -o _workspace/renderings

Got this Stack trace:

Traceback (most recent call last):
  File "ml-sharp/.venv/bin/sharp", line 8, in <module>
    sys.exit(main_cli())
             ~~~~~~~~^^
  File "ml-sharp/.venv/lib/python3.13/site-packages/click/core.py", line 1462, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "ml-sharp/.venv/lib/python3.13/site-packages/click/core.py", line 1383, in main
    rv = self.invoke(ctx)
  File "ml-sharp/.venv/lib/python3.13/site-packages/click/core.py", line 1850, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "ml-sharp/.venv/lib/python3.13/site-packages/click/core.py", line 1246, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "ml-sharp/.venv/lib/python3.13/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "ml-sharp/src/sharp/cli/render.py", line 61, in render_cli
    gaussians, metadata = load_ply(scene_path)
                          ~~~~~~~~^^^^^^^^^^^^
  File "ml-sharp/src/sharp/utils/gaussians.py", line 324, in load_ply
    colors = cs_utils.sRGB2linearRGB(colors)
  File "ml-sharp/src/sharp/utils/color_space.py", line 52, in sRGB2linearRGB
    return robust_where(
        sRGB <= THRESHOLD,
    ...<3 lines>...
        branch_false_safe_value=THRESHOLD,
    )
  File "ml-sharp/src/sharp/utils/robust.py", line 40, in robust_where
    input_2 = torch.where(~condition, input_2, branch_false_safe_value)
TypeError: where() received an invalid combination of arguments - got (numpy.ndarray, numpy.ndarray, float), but expected one of:
 * (Tensor condition)
 * (Tensor condition, Tensor input, Tensor other, *, Tensor out = None)
 * (Tensor condition, Number self, Tensor other)
      didn't match because some of the arguments have invalid types: (numpy.ndarray, numpy.ndarray, float)
 * (Tensor condition, Tensor input, Number other)
      didn't match because some of the arguments have invalid types: (numpy.ndarray, numpy.ndarray, float)
 * (Tensor condition, Number self, Number other)
      didn't match because some of the arguments have invalid types: (numpy.ndarray, numpy.ndarray, float)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions