How TiTok tokenization works
mainUnlike standard Vision Transformers that tokenize every spatial patch, TiTok tokenizes a fixed set of num_latent_tokens.
- Patching: The image is divided into patches and projected to
dim. - Positioning: Absolute position embeddings are added to the patch tokens.
- Latent Concatenation: A set of learnable
latentsis concatenated with the patch tokens. - Encoding: An
Encoderprocesses the combined sequence. - Quantization: The sequence is split, and only the
latentsportion is passed through the Vector Quantizer (vq). This produces the discrete codebook indices. - Decoding: The quantized latents are passed through a
Decoderand converted back into image patches to reconstruct the original image.