ranahanocka / MeshCNN

Convolutional Neural Network for 3D meshes in PyTorch
MIT License
1.61k stars 320 forks source link

Technical details in edge feature calculation #88

Open MaroonAmor opened 4 years ago

MaroonAmor commented 4 years ago

Hi, @ranahanocka thanks for sharing your nice work.

I have a question about the edge feature calculation in the "mesh_prepare.py" file.

Is there any reason that you use the function fixed_division(to_div, epsilon) with epsilon=0.1 for the division (in the mesh_prepare.py)? Is it too large?

In the current version, this division strategy exists in functions angles_from_faces(mesh, edge_faces, faces), get_opposite_angles(mesh, edge_points, side), and get_ratios(mesh, edge_points, side) followed by clip(-1, 1). The epsilon value of 0.1 is added to all the vectors to be normalized.

Also, I think it is not correct to calculate the angle by clipping the cos value in [-1, 1]. Is it gonna affect the angle value a lot after modifying the cos value?

Is it better for the dihedral angle of two neighbor faces to differentiate between the concave and convex cases? In the current vision, the angle is always positive (no difference between such two cases above), right?

Could you give me more details on the reason or advantages in your implementation?

Thank you

ranahanocka commented 4 years ago

Hi @MaroonAmor ,

Arc cosine is defined between -1 ≤ x ≤1, and so due to any floating point arithmetic, we ensure this is the case with the clip, here: https://github.com/ranahanocka/MeshCNN/blob/15b83cc6a4db968baf6cf595df78995a9c2dcee3/models/layers/mesh_prepare.py#L412-L413 and here: https://github.com/ranahanocka/MeshCNN/blob/15b83cc6a4db968baf6cf595df78995a9c2dcee3/models/layers/mesh_prepare.py#L222-L223

The reason for the fixed_division is to handle the degenerate case when the denominator is zero, so we add a fixed value to the denominator for numerical stability.

MaroonAmor commented 4 years ago

Hi @ranahanocka,

Thanks a lot for your explanation about the numeric stability during division.

Could you introduce more details about the dihedral angle between two neighbor faces? Why all angles are positive?

I am wondering if signed angles could further help improve the segmentation accuracy. Thanks. :)

ranahanocka commented 4 years ago

Hi @MaroonAmor ,

I think that signed angles will be sensitive to order. Since we don't have a way to consistently define which face comes first, this just tells us if an angle is sharp, or not. I would guess that adding signed angles will hurt the performance for this reason, but feel free to try it out and let us know :)