GithubHelp home page GithubHelp logo

pipisjy / chamferdistancepytorch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thibaultgroueix/chamferdistancepytorch

0.0 0.0 0.0 78 KB

Chamfer Distance in Pytorch with f-score

License: MIT License

C++ 9.03% Python 36.07% Cuda 54.90%

chamferdistancepytorch's Introduction

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.

  • F - Score

CUDA VERSION

  • JIT compilation
  • Supports multi-gpu
  • 2D point clouds.
  • 3D point clouds.
  • 5D point clouds.
  • Contiguous() safe.

Python Version

  • Supports any dimension

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

  • 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

What is the chamfer distance ?

Stanford course on 3D deep Learning

Aknowledgment

Original backbone from Fei Xia.

JIT cool trick from Christian Diller

Troubleshoot

  • 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 

TODO:

  • Discuss behaviour of torch.min() and tensor.min() which causes issues in some pytorch versions

chamferdistancepytorch's People

Contributors

thibaultgroueix avatar chrdiller avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.