TL;DR
MambaStyle is a novel, single-stage encoder for StyleGAN inversion that replaces heavy Transformer blocks with efficient Vision State-Space Models (VSSMs). It achieves state-of-the-art reconstruction fidelity and editing quality while significantly reducing parameter counts and inference time, making high-quality real-time image manipulation more accessible.
What Problem Does This Paper Address?
Generative Adversarial Networks (GANs), specifically StyleGAN, have a remarkably structured latent space that allows us to edit images by simply moving along specific "directions" (e.g., adding a smile or changing age). However, the "inversion" process—mapping a real-world photo into this latent space—suffers from a persistent distortion-editability trade-off.
Optimization-based methods produce near-perfect reconstructions but are too slow for real-time use and often "overfit," making the resulting code hard to edit. Encoder-based methods are fast but typically struggle to capture fine details. Recent attempts to fix this by mapping images into high-dimensional feature spaces ($F_k$) have improved quality but resulted in massive, computationally expensive models. MambaStyle aims to break this cycle by providing high fidelity and editability without the heavy computational tax.
Methods
The core innovation of MambaStyle is the integration of Mamba (State-Space Models) into the GAN inversion pipeline. Unlike Transformers, which have quadratic complexity relative to sequence length, Mamba scales linearly, offering a more efficient way to capture long-range dependencies in data.
The architecture consists of two primary components:
- Multi-scale Mamba-based Encoder: This module uses an IResNet-34 backbone paired with VSSM modules. It processes the image at multiple scales to extract hierarchical features ($H_1, H_2, H_3$) and maps them to the $W^+$ latent space.
- Fuser Module: This is the "secret sauce" for high-fidelity editing. It takes the desired editing direction $d$ and fuses it directly with the spatial feature maps ($H_3$) from the encoder. This allows the model to apply localized, fine-grained transformations while preserving the original image's structural identity.
The system is trained in a single stage using paired data generated synthetically from StyleGAN itself. By sampling random noise and applying random editing directions, the model learns to invert and edit simultaneously without needing multi-phase training or pre-trained auxiliary encoders like e4e.
Datasets
The authors evaluated MambaStyle on two standard benchmarks:
- CelebA-HQ: A high-quality dataset of facial images.
- Stanford Cars: A dataset focused on vehicle inversion and attribute editing (e.g., color changes).
Training was performed using synthetic samples generated from FFHQ (faces) and LSUN Cars pre-trained StyleGAN2 models.
Key Insights and Ideas
- SSMs for Vision: The paper demonstrates that the 2D Selective Scan (SS2D) mechanism used in VSSMs is highly effective for GAN inversion. It captures the global context necessary for latent mapping while remaining lightweight.
- Spatial Modulation: By injecting editing instructions into the spatial feature maps ($F_k$ space) via the Fuser, MambaStyle avoids the "identity bleed" common in methods that only manipulate global latent codes. This keeps the background and non-target features (like a hat or jewelry) stable during edits.
- Efficiency as a First-Class Citizen: MambaStyle occupies a unique "sweet spot" in the design space. As shown in the plot below, it achieves higher perceptual fidelity (MS-SSIM) than much larger models like SFE or StyleRes.
Key Results
- Superior Fidelity: MambaStyle achieved the highest MS-SSIM (0.986) on the CelebA-HQ dataset, outperforming the previous state-of-the-art, SFE (0.922).
- Speed and Complexity: The model is significantly faster and leaner. It boasts an inference time of 0.023s per image, compared to 0.070s for SFE and 0.275s for HyperStyle. It uses roughly 4x fewer parameters than some competing high-fidelity encoders.
- Qualitative Excellence: Visually, MambaStyle preserves tricky details—like the texture of a woven hat or specific makeup styles—that other encoders often blur or miscolor during inversion and editing.
Limitations and Future Work
While MambaStyle significantly advances efficiency, the authors note that the Fuser module is critical; removing it leads to a sharp drop in performance, indicating that the $W^+$ space alone is still insufficient for perfect inversion.
Future work could explore applying this Mamba-based architecture to even more complex domains, such as full-body human inversion or video editing, where the linear scaling of SSMs would provide an even greater advantage over traditional Transformer-based approaches.
Summary updated