Downloads · 30 days
0
bdck/point-sam-inference
point-sam-inference is a machine learning model from bdck. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
A clean, self-contained Python inference package for Point-SAM (ICLR 2025), extending SAM's promptable segmentation to 3D point clouds.
Downloads · 30 days
0
Access
Public
Updated May 7, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.py75.9 KB · 89%
From the Hugging Face model README
A clean, self-contained Python inference package for Point-SAM (ICLR 2025), extending SAM's promptable segmentation to 3D point clouds.
Paper: Point-SAM: Promptable 3D Segmentation Model for Point Clouds
Original Code: github.com/zyc00/Point-SAM
Pretrained Weights:yuchen0187/Point-SAM
pip install torch timm safetensors huggingface_hub numpy
from point_sam import PointSAM, load_pointcloud
# 1. Load a point cloud (PLY or PCD)
coords, rgb, original = load_pointcloud("scene.ply")
# coords: [N, 3] normalized to [-1, 1]
# rgb: [N, 3] in [0, 255]
# 2. Load the pretrained model (downloads weights from HF Hub)
model = PointSAM.from_pretrained(checkpoint_path="model.safetensors", device="cuda")
# 3. Cache the cloud for fast repeated queries
model.set_pointcloud(coords, rgb)
# 4. Segment with a prompt point (in normalized [-1, 1] space)
masks, iou_scores = model.predict(
coords=None, # use cached cloud
rgb=None,
prompt_point=[0.5, 0.1, -0.2],
prompt_label=1, # 1 = foreground, 0 = background
multimask_output=True,
)
# 5. Pick the best mask by IoU score
best_mask = masks[iou_scores.argmax()] # [N] boolean
Command-line example:
python examples/segment_ply.py scene.ply 0.5 0.1 -0.2 --checkpoint model.safetensors
Point-SAM is a direct 3D adaptation of SAM. It has the same three-part architecture, but replaces the 2D image backbone with a point cloud encoder.
The encoder turns an unstructured point cloud into a compact set of patch embeddings — the 3D equivalent of image patches.
Voronoi Tokenizer (the key speed trick)
G center points from the cloud via Farthest Point Sampling (FPS). This spreads centers evenly across the shape.G patch embeddings, each summarizing a local neighborhood.Vision Transformer (ViT) backbone
eva02_large_patch14_448 for the large variant, or eva_giant_patch14_560 for giant.[B, num_patches, D] embedding tensor (default D = 256).None, so a learned "no mask" embedding is used instead.The decoder is a two-way transformer — identical in spirit to SAM's decoder:
The decoder always outputs 4 candidates (1 default + 3 multimask). The first candidate is a "safe" single mask; the other three are alternatives at different granularities.
During training, Point-SAM simulates a user iteratively adding prompts:
At inference time you only do a single forward pass with whatever prompt you provide — the model was trained to produce a good mask even from one point.
| Format | Notes |
|---|---|
| PLY | ASCII .ply with x y z r g b columns |
| PCD | ASCII .pcd with x y z r g b columns (Point Cloud Library format) |
Both loaders normalize coordinates to a unit sphere in [-1, 1] and scale colors to [0, 255]. This normalization is required — the positional encoding will raise a ValueError if coordinates fall outside [-1, 1].
If your cloud has > 100k points, increase the patch resolution to avoid OOM:
model.adjust_patch_params(num_groups=2048, group_size=256)
The default is num_groups=1024, group_size=256 for the large model.
| Original | This Package |
|---|---|
Requires hydra + omegaconf for config | Pure Python, no YAML configs needed |
Requires compiling torkit3d (CUDA ops) | Pure-PyTorch FPS, KNN, and index operations |
Requires compiling apex for FusedLayerNorm | Standard nn.LayerNorm by default; apex optional |
| Scattered evaluation scripts | One clean PointSAM class with predict() |
| Heavy training codebase | Only inference + minimal model code |
@inproceedings{
zhou2025pointsam,
title={Point-{SAM}: Promptable 3D Segmentation Model for Point Clouds},
author={Yuchen Zhou and Jiayuan Gu and Tung Yen Chiang and Fanbo Xiang and Hao Su},
booktitle={The Thirteenth International Conference on Learning Representations},
year={2025},
url={https://openreview.net/forum?id=yXCTDhZDh6}
}
MIT (same as the original repository).
<!-- ml-intern-provenance -->This model repository was generated by ML Intern, an agent for machine learning research and development on the Hugging Face Hub.
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "bdck/point-sam-inference"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
For non-causal architectures, replace AutoModelForCausalLM with the appropriate AutoModel class.