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")
|