Point cloud segmentation
Collection
61 items • Updated
An OctFormer point cloud segmentation model (octree-based windowed transformer). Trained on ScanNet (20 classes).
pip install torch-pointcloud
This checkpoint also needs ocnn and dwconv, which need a build matching your torch and CUDA: see the installation guide.
import torch
import torch_pointcloud as tp
from torch_pointcloud.utils.data import collate
model, info = tp.create_model(
"octformer-base.scannet20.octree-nn",
task="segmentation",
pretrained=True,
return_info=True,
)
model = model.cuda().eval() # GPU-only kernels
# synthetic sample with the keys a dataset provides
num_points = 8192
sample = {
"pos": torch.randn(num_points, 3),
"color": torch.rand(num_points, 3) * 255,
"normal": torch.randn(num_points, 3),
"segment": torch.zeros(num_points, dtype=torch.long),
}
data = info["transform"](sample)
data = collate([data])
data = {key: value.cuda() for key, value in data.items()}
with torch.no_grad():
logits = model(data.get("x"), data["octree"], data["octree"].depth, data["pos"], data["batch"])
with torch.no_grad():
features = model.forward_features(data.get("x"), data["octree"], data["octree"].depth)
model.reset_classifier(num_classes=0)
with torch.no_grad():
features = model(
data.get("x"),
data["octree"],
data["octree"].depth,
data["pos"],
data["batch"],
) # (N, 168)
@article{wang2023octformer,
title = {OctFormer: Octree-based Transformers for 3D Point Clouds},
author = {Peng-Shuai Wang},
journal = {ACM Transactions on Graphics},
volume = {42},
number = {4},
year = {2023}
}
@inproceedings{dai2017scannet,
title = {ScanNet: Richly-annotated 3D Reconstructions of Indoor Scenes},
author = {Angela Dai and Angel X. Chang and Manolis Savva and Maciej Halber and Thomas Funkhouser and Matthias Nießner},
booktitle = {CVPR},
year = {2017}
}
@software{dujardin2026pytorchpointcloud,
author = {Arthur Dujardin},
title = {PyTorch PointCloud},
year = {2026},
doi = {10.5281/zenodo.22159632},
url = {https://github.com/arthurdjn/pytorch-pointcloud},
}