I would expect the cosine similarity loss to have a large value in the second case because the normals are flipped in direction.
In my application I have a mesh that is small in the thickness dimension. When I compute the chamfer distance to the target shape, I want the inner and outer surfaces of the mesh to match appropriately with the target shape. Since the normals have roughly opposite orientation, I would expect that using the cosine similarity functionality of chamfer_distance would help. But because of the issue I point out here, it does not work as I would hope.
Loss is near zero for normals with opposite orientation
The use of
torch.abs
in the following lines ends up assigning a small loss to normals that are of opposite orientation,Example
I would expect the cosine similarity loss to have a large value in the second case because the normals are flipped in direction.
In my application I have a mesh that is small in the thickness dimension. When I compute the chamfer distance to the target shape, I want the inner and outer surfaces of the mesh to match appropriately with the target shape. Since the normals have roughly opposite orientation, I would expect that using the cosine similarity functionality of
chamfer_distance
would help. But because of the issue I point out here, it does not work as I would hope.