Skip to content

Instantly share code, notes, and snippets.

View JUSTWILLPOWER's full-sized avatar
🎯
Focusing

JUSTWILLPOWER JUSTWILLPOWER

🎯
Focusing
View GitHub Profile
@justanhduc
justanhduc / pc2voxel.py
Last active July 1, 2025 14:57
PyTorch pointcloud to voxel
import neuralnet_pytorch as nnt
import torch as T
from torch_scatter import scatter_add
def pointcloud2voxel_fast(pc: T.Tensor, voxel_size: int, grid_size=1., filter_outlier=True):
b, n, _ = pc.shape
half_size = grid_size / 2.
valid = (pc >= -half_size) & (pc <= half_size)
valid = T.all(valid, 2)