-
Notifications
You must be signed in to change notification settings - Fork 64
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
Support for quads #54
Comments
@pathquester hey! yea, maybe i can slot that into my limited time left what are quads? is it just building meshes out of rectangles? |
as you can tell, i know nothing about the domain 🤣 |
@lucidrains Hi, awesome!! Yeah instead of triangular meshes, quad meshes make modeling a joy since you can add edge loops easily and subdivide further, among other benefits. If it remains limited to triangular meshes, that means we'll very often have to retopologize the mesh generated afterwards. |
@pathquester if it just means adding an extra vertex to each face (4 vertices instead of 3), that would be easy. do people ever mix quads and triangles in the same mesh? that may complicate things |
@pathquester wait, i'm geometrically challenged, but isn't it true that every quad can be broken into two triangles? |
@pathquester let me read up on the subject first to get a surface level understanding. will get back to this maybe near month's end, once i wrap up a project in flight |
@lucidrains They can be mixed yes although quads-only is arguably better than mixed, supporting just that should be ideal. That is fantastic, I would be very happy to help with this. Yes that's true also more quads thus increase the resolution, subdivision surface modifiers are mostly associated with quads. |
@pathquester maybe the issue is that when you have the attention net spit out the vertices, with 4 it may be difficult for it to maintain that they are within the same plane. yeah i'm not sure if it will work |
anyways, i know nothing lol i'll get back to you on this |
@lucidrains Ah yeah there may be challenges. Anyhow, many thanks!! |
@MarcusLoppe oh yes, now I recall ok, I think I should be able to do this before mid March |
@lucidrains |
yeah! and also when decoding from attention net, have to terminate on multiple of 4s |
believe face edges logic stays the same |
@MarcusLoppe you'll be doing something no one has ever done. top of the line research 🤣 |
have a feeling quads will require synthetic pretraining, however. also on sampling will need to snap malformed quads to nearest plane |
@lucidrains
Why synthetic pre-training and snapping? The data it generates would just contain a extra vertex, that doesn't seem such a dramatic change? |
@MarcusLoppe i think with vertices, you can generate invalid quads (the 4 points do not lie in the same plane). but like i said before, i'm geometrically challenged lol |
I don't think so. this is the first work to autoregress triangles, so surely no one has tried quads |
@lucidrains that's exactly why quads are interesting. By not lying on the same plane they allow you to describe more complex shapes. |
forgive ignorance, but how do you render a quad that has vertices not in the same plane? |
@lucidrains Thread about non-coplanar quads: But one thing I'm not sure about if it's always possible to convert into quads from triangles, for example the image below; blender is quite a capable software but it looks like a triangle unless it's a quad with one duplicated vertex. |
that's so cool! ok I'm more optimistic about quads now 🤣 |
@MarcusLoppe decided I'll just knock it out Sunday morning, if you don't get to it first |
I'll probably have tried and failed a couple times till then, but we'll see 😄 Any idea regarding the issue about not all triangles can be converted to quads? Are you going for the idea about adding a extra dimension on the face mask for padding or just force the triangles into quads with a duplicated vertex? |
@lucidrains
|
@MarcusLoppe hey, very good question! i think it should! investigated this before building out the autoencoder, and noticed this setting |
without knowing graph neural net literature very well, i assume they usually add the self edges with that function during loading of the data. it would make sense, as the paper only had sageconvs, and usually in any neural network you need some sort of connection to self (ie feedforwards in transformer) |
let me know if you find otherwise |
i didn't think that far haha, but duplicated vertex sounds like a good idea. the correct way is probably to have a dummy pad vertex that the transformer predicts, so a triangle would be a quad with a pad vertex. that would require an extra token on the transformer and some other engineering |
Ah, correct, it seems like the GCN's uses self-loops:
I think I'd let you figure out if it's possible, I can't even get past the project_in layer 😢 |
got it done this morning, at the expense of another project. hope this goes somewhere! i'll fix the derived features before mid March, for quads it is a bit different. import torch
from meshgpt_pytorch import (
MeshAutoencoder,
MeshTransformer
)
# autoencoder
autoencoder = MeshAutoencoder(
num_discrete_coors = 128,
quads = True
)
# mock inputs
vertices = torch.randn((2, 121, 3)) # (batch, num vertices, coor (3))
faces = torch.randint(0, 121, (2, 64, 4)) # (batch, num faces, vertices (4))
# make sure faces are padded with `-1` for variable lengthed meshes
# forward in the faces
loss = autoencoder(
vertices = vertices,
faces = faces
)
loss.backward()
# after much training...
# you can pass in the raw face data above to train a transformer to model this sequence of face vertices
transformer = MeshTransformer(
autoencoder,
dim = 512,
max_seq_len = 768,
quads = True
)
loss = transformer(
vertices = vertices,
faces = faces
)
loss.backward()
# after much training of transformer, you can now sample novel 3d assets
faces_coordinates, face_mask = transformer.generate() |
@MarcusLoppe if you want to still contribute, def welcome you to look into breaking up the derived features for triangles vs quads. based on the way you analyze things (and the way you code), i think you are on your way to becoming a great ML engineer. i'm thinking, perhaps for quads, it should be good for the network to know whether the 4 points are coplanar or not. as for normals, think you can get away by breaking the quad into two triangles and just offering the discretized normal for both triangles |
ok, i got to leave this project for reals now. already done enough for it |
Alright 😄 I thank you very much @lucidrains for the project and all that you have done, good luck on your other projects ❤️
Can't promise too much but I'll see if I can manage to get it done. But I can report that quads works 😄 Instead of using 5688 tokens it just used 3792 tokens which is about 36% token reduction 😮 Only downside is that using mixed quads and triangles doesn't work, it triggers some fatal cuda error so I can't provide any errors. I got the autoencoder to 0.29 loss after 45 epochs, and the transformer to 0.03 after 10minutes. For the autoencoder I generated the codes and then let it decode them, it was very accurately (0.00002 MSE loss). |
woohoo! thank you Marcus for the quick validation! more helpful to me than you could know |
That's really wonderful!! Kudos! |
Would it be within the scope of the project to also support quads for meshes? That would add tremendous utility.
The text was updated successfully, but these errors were encountered: