Skip to main content

MaskBit - Pytorch (wip)

Implementation of the proposed MaskBit from Bytedance AI

This paper can be viewed as a modernized version of the architecture from Taming Transformers from Esser et al.

They use the binary scalar quantization proposed in MagVit2 in their autoencoder, and then non-autoregressive mask decoding, where the masking is setting the bit (-1 or +1) to 0, projected for the transformer without explicit embeddings for the trit

Usage

import torch
from maskbit_pytorch import BQVAE, MaskBit

images = torch.randn(1, 3, 64, 64)

# train vae

vae = BQVAE(
    image_size = 64,
    dim = 512
)

loss = vae(images, return_loss = True)
loss.backward()

# train maskbit

maskbit = MaskBit(
    vae,
    dim = 512,
    bits_group_size = 512,
    depth = 2
)

loss = maskbit(images)
loss.backward()

# after much training

sampled_image = maskbit.sample() # (1, 3, 64, 64)

Citations

@inproceedings{Weber2024MaskBitEI,
    title   = {MaskBit: Embedding-free Image Generation via Bit Tokens},
    author  = {Mark Weber and Lijun Yu and Qihang Yu and Xueqing Deng and Xiaohui Shen and Daniel Cremers and Liang-Chieh Chen},
    year    = {2024},
    url     = {https://api.semanticscholar.org/CorpusID:272832013}
}

Metadata

Release files for maskbit-pytorch 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for maskbit-pytorch 0.0.2
File Size Uploaded
maskbit_pytorch-0.0.2.tar.gz 285.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for maskbit-pytorch 0.0.2
File Interpreter ABI Platform
maskbit_pytorch-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 298.4 kB

Release files / maskbit_pytorch-0.0.2.tar.gz

Download URL maskbit_pytorch-0.0.2.tar.gz
Size 285.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8e4ff775594d0bf11822352ab423f9ad543eb0d5137ff59f91a7d654b5dd55bf
BLAKE2b-256 checksum
How to use checksums
2270e71008d095a51c62623618e262bdc2ab170aad2b78d3c046a3f1f7891ac7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release files / maskbit_pytorch-0.0.2-py3-none-any.whl

Download URL maskbit_pytorch-0.0.2-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d5a48b99faaad5cf5d4d5096de782188c2adba2d156ea7175bb333261b3fc3d
BLAKE2b-256 checksum
How to use checksums
9f4c9c2ed1c2440c76c902c71c83d52c4717010acee26f14ea5a9a05ff254710
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page