Skip to content

Commit b55506a

Browse files
authored
Update backbone example for v2.1.0 (#224)
Co-authored-by: ys-2020 <[email protected]>
1 parent 897096a commit b55506a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

examples/backbones.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
@torch.no_grad()
1111
def main() -> None:
1212
device = 'cuda:0' if torch.cuda.is_available() else 'cpu'
13+
from torchsparse.nn import functional as F
14+
F.set_kmap_mode('hashmap')
1315

1416
for backbone in [SparseResNet21D, SparseResUNet42]:
1517
print(f'{backbone.__name__}:')
@@ -23,8 +25,8 @@ def main() -> None:
2325
pcs -= np.min(pcs, axis=0, keepdims=True)
2426
pcs, indices = sparse_quantize(pcs, voxel_size, return_index=True)
2527
coords = np.zeros((pcs.shape[0], 4))
26-
coords[:, :3] = pcs[:, :3]
27-
coords[:, -1] = 0
28+
coords[:, 1:4] = pcs[:, :3]
29+
coords[:, 0] = 0
2830
coords = torch.as_tensor(coords, dtype=torch.int)
2931
feats = torch.as_tensor(feats[indices], dtype=torch.float)
3032
input = SparseTensor(coords=coords, feats=feats).to(device)

0 commit comments

Comments
 (0)