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
Update all files for BitDance-Tokenizer-diffusers
Browse files
test.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Test BitDance-Tokenizer-diffusers: load tokenizer autoencoders only (no full inference).
|
| 4 |
+
|
| 5 |
+
Self-contained: uses local bitdance_diffusers (copied from BitDance-14B-64x-diffusers).
|
| 6 |
+
"""
|
| 7 |
+
import sys
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
import torch
|
| 11 |
+
|
| 12 |
+
# Self-contained: add local path so bitdance_diffusers is found
|
| 13 |
+
BASE_DIR = Path(__file__).resolve().parent
|
| 14 |
+
sys.path.insert(0, str(BASE_DIR))
|
| 15 |
+
|
| 16 |
+
from bitdance_diffusers import BitDanceAutoencoder
|
| 17 |
+
|
| 18 |
+
REPO = str(BASE_DIR)
|
| 19 |
+
SUBFOLDERS = ["ae_d16c32", "ae_d32c128", "ae_d32c256"]
|
| 20 |
+
|
| 21 |
+
print("Loading BitDance-Tokenizer autoencoders...")
|
| 22 |
+
for subfolder in SUBFOLDERS:
|
| 23 |
+
ae = BitDanceAutoencoder.from_pretrained(REPO, subfolder=subfolder)
|
| 24 |
+
print(f" {subfolder}: z_channels={ae.z_channels}, patch_size={ae.patch_size}")
|
| 25 |
+
|
| 26 |
+
# Quick encode/decode test with ae_d16c32
|
| 27 |
+
ae = BitDanceAutoencoder.from_pretrained(REPO, subfolder="ae_d16c32")
|
| 28 |
+
x = torch.randn(1, 3, 64, 64)
|
| 29 |
+
z = ae.encode(x)
|
| 30 |
+
y = ae.decode(z)
|
| 31 |
+
assert y.shape == x.shape, f"decode shape {y.shape} != input {x.shape}"
|
| 32 |
+
print("encode/decode test passed")
|