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

Post Process 3d Assets #4

Open
adeerAI opened this issue Dec 8, 2023 · 5 comments
Open

Post Process 3d Assets #4

adeerAI opened this issue Dec 8, 2023 · 5 comments

Comments

@adeerAI
Copy link

adeerAI commented Dec 8, 2023

Hi, thank you for the wonderful code. I want to understand that, how can I post process the following as you mentioned in Usage. And, how do I run the code?

# after much training of transformer, you can now sample novel 3d assets

faces_coordinates = transformer.generate()

# (batch, num faces, vertices (3), coordinates (3))
# now post process for the generated 3d asset
@fire

This comment was marked as off-topic.

@fire
Copy link

fire commented Dec 10, 2023

So the mesh representation you want is

vertices = torch.randn((2, 121, 3))            # (batch, num vertices, coor (3))
faces = torch.randint(0, 121, (2, 64, 3))      # (batch, num faces, vertices (3))

Like for a 3d-simplex or tetrahedra.

vertices = torch.tensor([
    [0.0, 0.0, 0.0],  # Vertex 1
    [1.0, 0.0, 0.0],  # Vertex 2
    [0.0, 1.0, 0.0],  # Vertex 3
    [0.0, 0.0, 1.0]   # Vertex 4
]).unsqueeze(0)       # Add batch dimension

faces = torch.tensor([
    [0, 1, 2],        # Face 1
    [0, 1, 3],        # Face 2
    [0, 2, 3],        # Face 3
    [1, 2, 3]         # Face 4
]).unsqueeze(0)       # Add batch dimension

@fire
Copy link

fire commented Dec 10, 2023

I'll put a pr with my code for review.

@MarcusLoppe
Copy link
Contributor

MarcusLoppe commented Dec 10, 2023

I think there is some confusion. The output of the transformer is triangles and those contain vertexes.
Regarding the angles,area and normal's, I've already explained in the code review but to repeat; they are automatically calculated so only the vertices and faces (indices/index to the vertices array) is needed.

Some vertex can be duplicates since two triangles might use the same vertex, so you'll need to clean it up to be most memory effective.
As per below, each triangle contains a array with 3 vertices and each vertex contains the float values for XYZ (all though not sure about the order of the x y and z):

[[-0.8047,  0.1953,  0.8516],
[-0.3359,  0.8203,  0.9609],
[ 0.3672, -0.5859,  `0.0078]]

Output of 20 triangles:

output = transformer.generate()
print(output .shape)
print(output)

torch.Size([1, 20, 3, 3])
tensor([[[[-0.8047,  0.1953,  0.8516],
          [-0.3359,  0.8203,  0.9609],
          [ 0.3672, -0.5859,  0.0078]],

         [[-0.4922, -0.7578, -0.3828],
          [-0.2422,  0.2266,  0.2578],
          [-0.2578, -0.8516, -0.3516]],
...

@fire

This comment was marked as outdated.

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