TiTok - Pytorch
Project description
TiTok - Pytorch (wip)
Implementation of TiTok, proposed by Bytedance in An Image is Worth 32 Tokens for Reconstruction and Generation
Usage
import torch
from titok_pytorch.titok import TiTokTokenizer
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
Citations
@article{yu2024an,
author = {Qihang Yu and Mark Weber and Xueqing Deng and Xiaohui Shen and Daniel Cremers and Liang-Chieh Chen},
title = {An Image is Worth 32 Tokens for Reconstruction and Generation},
journal = {arxiv: 2406.07550},
year = {2024}
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
titok_pytorch-0.0.1.tar.gz
(1.3 MB
view hashes)
Built Distribution
Close
Hashes for titok_pytorch-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 199908fe6c05a678f4c1ed3adc28192a59a98681e454134364c9fa855fc1216e |
|
MD5 | df4c6c5f25b03bbc7cc1c879e7284c55 |
|
BLAKE2b-256 | 0aaf218b1ecb8005f68110b03591862c45d353a4f930e8a4c53ce7e7236dc909 |