MCPcopy Create free account
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / initial_voxelize

Function initial_voxelize

lib/spvcnn_utils.py:12–32  ·  view source on GitHub ↗
(z, init_res, after_res)

Source from the content-addressed store, hash-verified

10# z: PointTensor
11# return: SparseTensor
12def initial_voxelize(z, init_res, after_res):
13 new_float_coord = torch.cat(
14 [(z.C[:, :3] * init_res) / after_res, z.C[:, -1].view(-1, 1)], 1)
15
16 pc_hash = spf.sphash(torch.floor(new_float_coord).int())
17 sparse_hash = torch.unique(pc_hash)
18 idx_query = spf.sphashquery(pc_hash, sparse_hash)
19 counts = spf.spcount(idx_query.int(), len(sparse_hash))
20
21 inserted_coords = spf.spvoxelize(torch.floor(new_float_coord), idx_query,
22 counts)
23 inserted_coords = torch.round(inserted_coords).int()
24 inserted_feat = spf.spvoxelize(z.F, idx_query, counts)
25
26 new_tensor = SparseTensor(inserted_feat, inserted_coords, 1)
27 new_tensor.check()
28 z.additional_features['idx_query'][1] = idx_query
29 z.additional_features['counts'][1] = counts
30 z.C = new_float_coord
31
32 return new_tensor
33
34
35# x: SparseTensor, z: PointTensor

Callers 1

forwardMethod · 0.85

Calls 1

catMethod · 0.80

Tested by

no test coverage detected