Home

Awesome

pip install torch ninja

Pytorch Chamfer Distance.

Include a CUDA version, and a PYTHON version with pytorch standard operations. NB : In this depo, dist1 and dist2 are squared pointcloud euclidean distances, so you should adapt thresholds accordingly.

CUDA VERSION

Python Version

Usage

import torch, chamfer3D.dist_chamfer_3D, fscore
chamLoss = chamfer3D.dist_chamfer_3D.chamfer_3DDist()
points1 = torch.rand(32, 1000, 3).cuda()
points2 = torch.rand(32, 2000, 3, requires_grad=True).cuda()
dist1, dist2, idx1, idx2 = chamLoss(points1, points2)
f_score, precision, recall = fscore.fscore(dist1, dist2)

Add it to your project as a submodule

git submodule add https://github.com/ThibaultGROUEIX/ChamferDistancePytorch

Benchmark: [forward + backward] pass

Timing (sec * 1000)2D3D5D
Cuda Compiled1.21.41.8
Cuda JIT1.31.41.5
Python373737
Memory (MB)2D3D5D
Cuda Compiled529529549
Cuda JIT520529549
Python249524952495

What is the chamfer distance ?

Stanford course on 3D deep Learning

Aknowledgment

Original backbone from Fei Xia.

JIT cool trick from Christian Diller

Troubleshoot

--> Fix: Make sure to import torch before you import chamfer. --> Use pytorch.version >= 1.1.0

wget https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip
sudo unzip ninja-linux.zip -d /usr/local/bin/
sudo update-alternatives --install /usr/bin/ninja ninja /usr/local/bin/ninja 1 --force 

TODO: