-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84176c2
commit 82ea31e
Showing
4 changed files
with
70 additions
and
23 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
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,23 @@ | ||
import pytest | ||
import torch | ||
from titok_pytorch import TiTokTokenizer | ||
|
||
def test_titok(): | ||
|
||
images = torch.randn(2, 3, 256, 256) | ||
|
||
titok = TiTokTokenizer(dim = 512) | ||
|
||
loss = titok(images) | ||
loss.backward() | ||
|
||
# after much training | ||
# extract codes for gpt, maskgit, whatever | ||
|
||
codes = titok.tokenize(images) | ||
|
||
# reconstructing images from codes | ||
|
||
recon_images = titok.codebook_ids_to_images(codes) | ||
|
||
assert recon_images.shape == images.shape |
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 @@ | ||
from titok_pytorch.titok import TiTokTokenizer |
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