krrish94 / chamferdist

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

How to set K more than 1 #9

Open brian3021 opened 3 years ago

brian3021 commented 3 years ago

Hi, thanks for sharing the code.

I was using chamferdist as my model loss, and it works very well.

And now I saw the 1.0.0 version of chamferdist has KNN points,

how can I switch the chamferdist into KNN points? Just set K into a number that what I want?

Or I have to call the KNN_points function in chamfer.py file? Because I did't see this in Example.py file.


Oh, one more question.

when I use chamferdist in version 0.3.0,

I just call chamfer function like: dist1, dist2, idx1, idx2 = chamfer(source_pts, target_pts) and then (torch.mean(dist1)) + (torch.mean(dist2)) to get the chamfer loss which I can get the chamfer distance from source_pts to target_pts and the chamfer distance from target_pts to source_pts at the same time, right? (Because I'm not pretty sure about this.)

And now in 1.0.0 version, I have to change the code into dist1, idx1 = chamfer(source_pts, target_pts) and dist2, idx2 = chamfer(target_pts, source_pts) because chamferdist only calculate in one way in version 1.0.0, right?

Thanks!

brian3021 commented 3 years ago

I have tried to call knn_points function from chamfer.py and I can set K more than 1,and calculating chamferdist sucessfully.

But I still wants to know the difference that the calculate direction when doing the chamferdist function between ver. 0.3.0 and ver 1.0.0 and also the meaning of dist we got.