MCPcopy Create free account
hub / github.com/JasonLSC/GSCodec_Studio / knn

Function knn

examples/utils.py:143–147  ·  view source on GitHub ↗
(x: Tensor, K: int = 4)

Source from the content-addressed store, hash-verified

141
142
143def knn(x: Tensor, K: int = 4) -> Tensor:
144 x_np = x.cpu().numpy()
145 model = NearestNeighbors(n_neighbors=K, metric="euclidean").fit(x_np)
146 distances, _ = model.kneighbors(x_np)
147 return torch.from_numpy(distances).to(x)
148
149
150def rgb_to_sh(rgb: Tensor) -> Tensor:

Calls

no outgoing calls

Tested by

no test coverage detected