MCPcopy Create free account
hub / github.com/city-super/Octree-GS / tensor2rgb

Function tensor2rgb

utils/visualize_utils.py:54–67  ·  view source on GitHub ↗
(
    tensor: th.Tensor, x_max: Optional[float] = None, x_min: Optional[float] = None
)

Source from the content-addressed store, hash-verified

52
53
54def tensor2rgb(
55 tensor: th.Tensor, x_max: Optional[float] = None, x_min: Optional[float] = None
56) -> np.ndarray:
57 x = tensor.data.cpu().numpy()
58 if x_min is None:
59 x_min = x.min()
60 if x_max is None:
61 x_max = x.max()
62
63 gain = 255 / np.clip(x_max - x_min, 1e-3, None)
64 x = (x - x_min) * gain
65 x = x.clip(0.0, 255.0)
66 x = x.astype(np.uint8)
67 return x
68
69
70def tensor2image(

Callers 2

tensor2rgbjetFunction · 0.85
tensor2imageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected