Preserve ray and image batch dimensions in the grayscale colormap

This commit is contained in:
Afloat committed 2026-11-07 02:55:01 +08:00
1 parent 50e0e3c70c
commit 63c5e5842e
2 files changed
+15 -1

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
import pytest
import torch
from nerfstudio.utils.colormaps import ColormapOptions, apply_colormap
@pytest.mark.parametrize("shape", [(5, 1), (2, 4, 1), (2, 3, 4, 1)])
def test_grayscale_preserves_batch_dimensions(shape):
values = torch.linspace(0, 1, torch.Size(shape).numel()).reshape(shape)
rgb = apply_colormap(values, ColormapOptions(colormap="gray"))
assert rgb.shape == (*shape[:-1], 3)
for channel in range(3):
torch.testing.assert_close(rgb[..., channel], values[..., 0])