Instructions to use BiliSakura/BitDance-Tokenizer-diffusers with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use BiliSakura/BitDance-Tokenizer-diffusers with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("BiliSakura/BitDance-Tokenizer-diffusers", dtype=torch.bfloat16, device_map="cuda") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Notebooks
- Google Colab
- Kaggle
| #!/usr/bin/env python3 | |
| """ | |
| Test BitDance-Tokenizer-diffusers: load tokenizer autoencoders only (no full inference). | |
| Self-contained: uses local bitdance_diffusers (copied from BitDance-14B-64x-diffusers). | |
| """ | |
| import sys | |
| from pathlib import Path | |
| import torch | |
| # Self-contained: add local path so bitdance_diffusers is found | |
| BASE_DIR = Path(__file__).resolve().parent | |
| sys.path.insert(0, str(BASE_DIR)) | |
| from bitdance_diffusers import BitDanceAutoencoder | |
| REPO = str(BASE_DIR) | |
| SUBFOLDERS = ["ae_d16c32", "ae_d32c128", "ae_d32c256"] | |
| print("Loading BitDance-Tokenizer autoencoders...") | |
| for subfolder in SUBFOLDERS: | |
| ae = BitDanceAutoencoder.from_pretrained(REPO, subfolder=subfolder) | |
| print(f" {subfolder}: z_channels={ae.z_channels}, patch_size={ae.patch_size}") | |
| # Quick encode/decode test with ae_d16c32 | |
| ae = BitDanceAutoencoder.from_pretrained(REPO, subfolder="ae_d16c32") | |
| x = torch.randn(1, 3, 64, 64) | |
| z = ae.encode(x) | |
| y = ae.decode(z) | |
| assert y.shape == x.shape, f"decode shape {y.shape} != input {x.shape}" | |
| print("encode/decode test passed") | |