-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add optional adaptive rmsnorm on text embed conditioning
- Loading branch information
1 parent
ac67dd5
commit b6d870c
Showing
6 changed files
with
100 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Pytest | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install -e .[test] | ||
- name: Test with pytest | ||
run: | | ||
python -m pytest tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '1.2.22' | ||
__version__ = '1.4.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[aliases] | ||
test=pytest | ||
|
||
[tool:pytest] | ||
addopts = --verbose -s | ||
python_files = tests/*.py | ||
python_paths = "." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import pytest | ||
import torch | ||
|
||
from meshgpt_pytorch import ( | ||
MeshAutoencoder, | ||
MeshTransformer | ||
) | ||
|
||
@pytest.mark.parametrize('adaptive_rmsnorm', (True, False)) | ||
def test_readme(adaptive_rmsnorm): | ||
|
||
autoencoder = MeshAutoencoder( | ||
num_discrete_coors = 128 | ||
) | ||
|
||
# mock inputs | ||
|
||
vertices = torch.randn((2, 121, 3)) # (batch, num vertices, coor (3)) | ||
faces = torch.randint(0, 121, (2, 64, 3)) # (batch, num faces, vertices (3)) | ||
|
||
# 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, | ||
num_sos_tokens = 1, | ||
fine_cross_attend_text = True, | ||
text_cond_with_film = False, | ||
condition_on_text = True, | ||
coarse_adaptive_rmsnorm = adaptive_rmsnorm | ||
) | ||
|
||
loss = transformer( | ||
vertices = vertices, | ||
faces = faces, | ||
texts = ['a high chair', 'a small teapot'] | ||
) | ||
|
||
loss.backward() | ||
|
||
faces_coordinates, face_mask = transformer.generate(texts = ['a small chair'], cond_scale = 3.) |