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.
- F - Score
- JIT compilation
- Supports multi-gpu
- 2D point clouds.
- 3D point clouds.
- 5D point clouds.
- Contiguous() safe.
- Supports any dimension
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
- CUDA 10.1, NVIDIA 435, Pytorch 1.4
- p1 : 32 x 2000 x dim
- p2 : 32 x 1000 x dim
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
- Discuss behaviour of torch.min() and tensor.min() which causes issues in some pytorch versions