krrish94 / chamferdist

Pytorch package to compute Chamfer distance between point sets (pointclouds).
Other
290 stars 50 forks source link

Add point reduction parameter #20

Closed charlieppark closed 1 year ago

charlieppark commented 1 year ago

I was using this chamferdist package and Pytorch3D for getting chamfer distance of point clouds.

I found that there is a difference in results compared to that of Pytorch3D. https://github.com/krrish94/chamferdist/issues/14

It was because this package only supports control of batch reduction method.

In detail, pytorch uses mean for both batch reduction and point reduction by default as the code below:

pytorch3d.loss.chamfer_distance(x, y, ..., batch_reduction: Optional[str] = 'mean', point_reduction: str = 'mean', ...)[source]

However, this package uses mean as batch reduction but uses sum as point reduction, and doesn't support control of point reduction method.

Thus I added point reduction parameter.

Now the results are the same with that of Pytorch3D if we set both reduction as "mean" and bidirectional=True

So I opened a PR and I didn't know that I might open an issue first.

@krrish94 Can you check if #19 and source of it is ok?

BTW, thank you for making this package. It helped me a lot :)

charlieppark commented 1 year ago

Close this issue because PR @ #19 has been merged