Emu3.5 complete image VQ codec
The full official image encoder, 131072×256 codebook, quantization projections and image decoder. The original safetensors file, names, shapes, dtypes and tensor payloads are unchanged. Source: BAAI/Emu3.5-VisionTokenizer, fixed revision a5c45bdb8084763048e094ae124778bfeca7d5ee. Vendored native implementation and preprocessing are pinned in code_provenance.json. Original Apache-2.0 notices are retained.
from huggingface_hub import snapshot_download
import sys, torch
folder = snapshot_download('gatilin/emu3_5_visual_codec')
sys.path.insert(0, folder)
from component import load_model
codec = load_model(folder)
x = torch.zeros(1, 3, 256, 256) # RGB NCHW, values in [-1, 1]
with torch.inference_mode():
quantized, _, info = codec.encode(x)
ids = info[-1].reshape(1, 16, 16)
reconstruction = codec.decode_code(ids, shape=(1, 16, 16))
Native image preprocessing resizes with PIL bicubic to a target image area, rounds dimensions to multiples of 16, then maps RGB bytes with pixel / 127.5 - 1. See the unmodified native/input_utils.py for smart_resize. Image token IDs are local codebook IDs from 0 to 131071; the Emu3.5 language tokenizer additionally formats row separators, resolution and <|visual token 000000|> strings. This package does not silently apply language-token offsets.
The native quantizer selects maximum dot product with codebook vectors. It is not a Euclidean-nearest-neighbor implementation. Run python validate.py for source LFS SHA-256, strict 543-entry loading, square/rectangular encoding, ID bounds, codebook lookup, native assignment and decode-code parity. validation.json records executed results. Synthetic reconstruction checks do not establish image quality or full Emu3.5 reasoning/generation performance. This 2D image codec has no independently tested temporal-video interface.
- Downloads last month
- 7
Model tree for gatilin/emu3_5_visual_codec
Base model
BAAI/Emu3.5-VisionTokenizer