Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NaN value in the rendered result #43

Closed
quanhua92 opened this issue Oct 16, 2020 · 4 comments
Closed

NaN value in the rendered result #43

quanhua92 opened this issue Oct 16, 2020 · 4 comments

Comments

@quanhua92
Copy link

quanhua92 commented Oct 16, 2020

Describe the bug
I am working on a custom Renderer with Scene3DPytorch and ColoredTriMeshPytorch. However, I encountered a NaN in the output tensor of the scene.render method.
Here is the gist contains my code: link to code
The data for vertices and faces can be download at link to data

To Reproduce
Steps to reproduce the behavior:

  1. Go to link to code
  2. Download vertices.npz and faces.npz: link to data
  3. Run the script nanproblem.py
  4. See error:
  • You can see that there are 387 nan values in the img tensor and the grad for the trans tensor is also nan
    print("nan counts = ", img[torch.isnan(img)].shape) # nan counts = torch.Size([387])
    print("trans grad", trans.grad) # trans grad tensor([nan, nan, nan])

Expected behavior
I expected to have a valid gradient in the trans.grad

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome
  • Version: 0.1.15 for NaN error.
    I have AssertionError on 0.1.17 at assert self.adjacencies.is_manifold
    Will update if have NaN error on 0.1.17
@quanhua92
Copy link
Author

The vertices and faces are from a model that I am working on Open3D lib.
In DEODR 0.1.17, I can see that mesh.adjacencies.is_closed and mesh.adjacencies.is_manifold are both false.

I used some utility methods from Open3D lib on my mesh in Open3D and here are some results:

  • open3d_mesh.is_watertight() => False
  • open3d_mesh.is_vertex_manifold() => False
  • open3d_mesh.is_edge_manifold() => True

Can you give me some ideas how to make sure mesh.adjacencies.is_closed and mesh.adjacencies.is_manifold are true?
Thanks

@martinResearch
Copy link
Owner

martinResearch commented Oct 27, 2020

Hi,
I had a look at your mesh in meshlab and there are some non manifold edges. Mesh repairing is out of the scope of my library. how was your mesh produced ? could you use a method that would produce watertight surfaces (Poisson reconstruction for example)? Otherwise you could try to repair your mesh in meshlab.

@quanhua92
Copy link
Author

Thanks. I used a neural network to output this mesh. I will find a way to produce watertight surfaces.

@martinResearch
Copy link
Owner

I have PR in progress that adds a method to extract the largest manifold subpart of a mesh using linear programming #51. However the best approach would be to have an algorithm that generates manifold surfaces in the first place

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants