STSCQ: Switchable Token-Specific Quantization
- Switchable Token-Specific Codebook Quantization is a method that employs token-specific codebooks and hierarchical grouping to achieve efficient compression of face images.
- It integrates with vector quantization models like VQ-VAE and VQGAN, delivering improved rate–distortion performance and superior identity preservation compared to global codebook methods.
- STSCQ uses a three-stage training process—including shared codebook initialization, token-specific refinement, and identity loss fine-tuning—to achieve significant gains in recognition accuracy at low bpp.
Switchable Token-Specific Codebook Quantization (STSCQ) is a codebook-based compression methodology optimized for face image compression at ultra-low bitrates. Distinguished from global codebook approaches, STSCQ introduces hierarchical image-level grouping and token-specific codebooks, significantly improving rate–distortion performance and face identity preservation. The design enables STSCQ to be integrated into any vector quantization-based representation learning pipeline, such as VQ-VAE, VQGAN, and TiTok, providing substantial gains over fixed-global codebook baselines at the same bits-per-pixel.
1. Model Structure and Pipeline
STSCQ operates atop the conventional "latent-space" autoencoder with vector quantization, consisting of the following principal components:
- Encoder (): Maps the input RGB face image to a grid of continuous latent tokens, .
- Routing and Codebook Selection: An image-level routing network selects a codebook group for the entire image: .
- Token-Specific Quantization: For each token position , a unique codebook is assigned, yielding .
- Decoder (): Reconstructs the image from quantized tokens: .
This architecture divides codebook capacity across image-level groups and token positions, yielding a total of codebooks, each of size , in contrast to a single monolithic codebook of size .
2. Mathematical Formalism and Losses
The formulation introduces distinct codebooks for each group and token position . For a given image, the active codebook group is selected, and each token is quantized via nearest-neighbor:
Bit allocation is explicitly determined:
The training objective is a composite of several losses:
- Reconstruction and VQ Commitment Loss:
where is the stop-gradient operator and denotes perceptual loss (e.g., LPIPS or VGG).
- Routing Loss ():
Promotes balanced codebook usage, confident routing, and minimal quantization error through entropy, decision, and quantization-average losses.
- Identity Consistency Loss:
Applied in fine-tuning, encouraging ArcFace-based recognition feature consistency.
3. Training Procedure
STSCQ employs a three-stage progressive training schedule:
- Stage 1: Switchable Token-Shared Codebooks
- Replace global codebook with image-level sub-codebooks (shared across tokens).
- Freeze encoder and decoder; optimize sub-codebooks and routing network.
- Minimize reconstruction and routing loss.
- Stage 2: Token-Specific Codebook Learning
- For each group and token , initialize from .
- Freeze encoder and decoder; optimize all and routing network.
- Minimize sum of token-wise quantization errors and routing loss.
- Stage 3: Decoder Fine-Tuning with Identity Loss
- Freeze codebooks and routing; train decoder only.
- Supplement loss with ArcFace-based identity regularization.
4. Quantization Capacity, Rate–Distortion, and BPP Efficiency
A global codebook of size provides high capacity but becomes infeasible at low bpp, where index sizes must be reduced. By setting , , effective total codebook capacity is preserved, since each group specializes in a specific facial attribute distribution. Token-specific codebooks further reduce the per-token quantization variance, maximizing usage, and substantially decreasing quantization errors at a given bpp. The model’s bpp is dictated primarily by , with the group overhead negligible for typical and .
5. Experimental Protocol and Evaluation
The method is trained and evaluated on standard face recognition datasets:
- Training Set: CASIA-WebFace (500K images, 10,575 identities)
- Evaluation Sets: LFW, CFP-FP, AgeDB, CPLFW, CALFW
- Preprocessing: crops, random horizontal flips
- Comparison Baselines: TiTok-S (), TiTok-L (), VQGAN/MaskGIT ()
- Optimization: AdamW, learning rate , run on 8 NVIDIA V100 GPUs
- Training Schedule: Stage 1: 100K steps; Stage 2: 400K; Stage 3: 100K
- Metrics: Mean recognition accuracy (MeanAcc, ArcFace), identity similarity (IDS), bpp
6. Quantitative Results and Ablation Insights
At comparable or lower bpp, STSCQ yields substantial improvements over baselines:
| Setting | bpp | Baseline MeanAcc | STSCQ MeanAcc | Baseline IDS | STSCQ IDS |
|---|---|---|---|---|---|
| MaskGIT-VQGAN+STSCQ, | 0.0503 | 90.70 | 93.51 | 0.6314 | 0.6659 |
| TiTok-S, , | 0.0234 | 87.56 | 91.66 | 0.5764 | 0.6120 |
| TiTok-L, | 0.0059 | 65.07 | 73.13 | — | — |
- Codebook Count (): Performance increases with up to 16 (for ), then degrades for due to routing instability.
- Token-Specific vs. Shared: Per-token splitting yields +1.6–2.5% MeanAcc gain at fixed bpp.
- Inference Routing: Confident routing (CR) matches or surpasses nearest-neighbor quantization, with reduced latency and storage.
- Codebook Utilization: Mean per-token utilization improved from ~54% (global/shared) to ~74% (token-specific), decreasing dead embeddings.
7. Implications, Generalization, and Limitations
STSCQ achieves high-fidelity, identity-preserving reconstructions at bitrates previously unattainable for face compression methods based on vector quantization. The approach generalizes to any codebook-based representation learning scheme, as the architecture and training objectives are modular. A plausible implication is that similar hierarchical, token-specific codebook strategies may benefit other semantic-rich domains beyond faces, especially at ultra-low bpp. The primary limitation is routing instability as the number of codebook groups becomes large. Further research may focus on robust routing mechanisms, capacity scaling, and extending these insights to non-facial image modalities.
For in-depth methodology, experiments, and implementation specifics, refer to "Switchable Token-Specific Codebook Quantization For Face Image Compression" (Wang et al., 27 Oct 2025).