pip install torch ninja
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.
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)
git submodule add https://github.com/ThibaultGROUEIX/ChamferDistancePytorch
Timing (sec 1000)* | 2D | 3D | 5D |
---|---|---|---|
Cuda Compiled | 1.2 | 1.4 | 1.8 |
Cuda JIT | 1.3 | 1.4 | 1.5 |
Python | 37 | 37 | 37 |
Memory (MB) | 2D | 3D | 5D |
---|---|---|---|
Cuda Compiled | 529 | 529 | 549 |
Cuda JIT | 520 | 529 | 549 |
Python | 2495 | 2495 | 2495 |
Stanford course on 3D deep Learning
Original backbone from Fei Xia.
JIT cool trick from Christian Diller
Undefined symbol: Zxxxxxxxxxxxxxxxxx
:--> 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