Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Pytorch package to compute Chamfer distance between point sets (pointclouds).

License

NotificationsYou must be signed in to change notification settings

haichen-ber/chamferdist

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NOTE: This implementation was stolen from thepytorch3d repo, and all I did was to simply repackage it.

krrish94

A simple example Pytorch module to compute Chamfer distance between two pointclouds.

Installation

You can install the package usingpip.

pip install chamferdist

Building from source

In your favourite python/conda virtual environment, execute the following commands.

NOTE: This assumes you have PyTorch installed already (preferably, >= 1.5.0; untested for earlier releases).

pythonsetup.pyinstall

Running (example)

That's it! You're now ready to go. Here's a quick guide to using the package. Fire up a terminal. Import the package.

>>>importtorch>>>fromchamferdistimportChamferDistance

Create two random pointclouds. Each pointcloud is a3D tensor with dimensionsbatchsize xnumber of points xnumber of dimensions.

>>>source_cloud=torch.randn(1,100,3).cuda()>>>target_cloud=torch.randn(1,50,3).cuda()

Initialize aChamferDistance object.

>>>chamferDist=ChamferDistance()

Now, compute Chamfer distance.

>>>dist_forward=chamferDist(source_cloud,target_cloud)>>>print(dist_forward.detach().cpu().item())

Here,dist is the Chamfer distance betweensource_cloud andtarget_cloud. Note that Chamfer distance is not bidirectional (and, in stricter parlance, it is not adistance metric).

The Chamfer distance in the backward direction, i.e.,target_cloud tosource_cloud can be computed in two ways. The naive way is to simply flip the order of the arguments, i.e.,

>>>dist_backward=chamferDist(target_cloud,source_cloud)

Another way is to use thereverse flag provided by theChamferDistance module, i.e.,

>>>dist_backward=chamferDist(source_cloud,target_cloud,reverse=True)>>>print(dist_backward.detach().cpu().item())

Typically, a symmetric version of the Chamfer distance is obtained, by summing the "forward" and the "backward" Chamfer distances. This is supported by thebidirectional flag.

>>>dist_bidirectional=chamferDist(source_cloud,target_cloud,bidirectional=True)>>>print(dist_bidirectional.detach().cpu().item())

Look at the example script for more details:example.py

Citing (the original implementation, PyTorch3D)

If you find this work useful, you might want to cite theoriginal implementation from which this codebase was borrowed (stolen!) - PyTorch3D.

@article{ravi2020pytorch3d,    author = {Nikhila Ravi and Jeremy Reizenstein and David Novotny and Taylor Gordon                  and Wan-Yen Lo and Justin Johnson and Georgia Gkioxari},    title = {Accelerating 3D Deep Learning with PyTorch3D},    journal = {arXiv:2007.08501},    year = {2020},}

About

Pytorch package to compute Chamfer distance between point sets (pointclouds).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Cuda59.8%
  • Python26.7%
  • C++12.9%
  • C0.6%

[8]ページ先頭

©2009-2025 Movatter.jp