StyleRes: Transforming the Residuals for Real Image Editing with StyleGAN

Hamza Pehlivan, Yusuf Dalva, Aysegul Dundar

Abstract

We present a novel image inversion framework and a training pipeline to achieve high-fidelity image inversion with high-quality attribute editing. Inverting real images into StyleGAN's latent space is an extensively studied problem, yet the trade-off between the image reconstruction fidelity and image editing quality remains an open challenge. The low-rate latent spaces are limited in their expressiveness power for high-fidelity reconstruction. On the other hand, high-rate latent spaces result in degradation in editing quality. In this work, to achieve high-fidelity inversion, we learn residual features in higher latent codes that lower latent codes were not able to encode. This enables preserving image details in reconstruction. To achieve high-quality editing, we learn how to transform the residual features for adapting to manipulations in latent codes. We train the framework to extract residual features and transform them via a novel architecture pipeline and cycle consistency losses. We run extensive experiments and compare our method with state-of-the-art inversion methods. Qualitative metrics and visual comparisons show significant improvements.

Introduction: The Distortion-Editability Trade-off

To edit a real-world image using StyleGAN, one must first "invert" it—finding the latent code that produces that specific image. However, researchers face a persistent hurdle known as the distortion-editability trade-off.

Low-rate latent spaces (like $W+$) are highly editable but lack the expressive power to capture fine details such as specific wrinkles, background textures, or small accessories. Conversely, high-rate latent spaces or features can capture every pixel perfectly, but they are not semantically linked to StyleGAN’s editing directions. If a user changes a person’s pose in the latent code, the high-resolution details (like an earring or a mole) often remain fixed in their original pixel coordinates, leading to "ghosting" or blur artifacts.

Visualizing the trade-off: (e1) shows ghosting artifacts in high-rate inversion during editing, while (f1) StyleRes maintains fidelity without artifacts.

StyleRes aims to bridge this gap, providing the pixel-perfect detail of high-rate features with the seamless flexibility of low-rate latent editing.

Methodology: Learning to Transform Residuals

The StyleRes framework consists of two main trainable components integrated with a fixed, pre-trained StyleGAN2 generator and a base encoder ($E_0$):

  • Residual Encoding ($E_1$): This module identifies the information missed by the base $W+$ code. By comparing the input image to the features generated by the fixed StyleGAN, it extracts "residual features"—the fine details and background information lost during initial inversion.
  • Transformation Module ($E_2$): This is the core innovation. Instead of statically adding residuals back, $E_2$ learns to transform those features based on the requested edit. For instance, if the latent code dictates a head rotation, $E_2$ calculates how the residual features (like a mole on the cheek) should spatially shift to remain consistent with the new pose.
  • Cycle Translation Path: To train the model without ground truth for edited real images, the authors utilize a cycle-consistency loss. The system simulates an edit, then "reverses" it, training the network to ensure the final output matches the original input image. This teaches the model general rules for feature transformation.

Experiments and Results

The model was evaluated on standard high-resolution benchmarks including FFHQ, CelebA-HQ, and Stanford Cars. StyleRes consistently outperformed state-of-the-art methods like e4e, HFGI, and HyperStyle across both quantitative and qualitative metrics.

Qualitative comparison of StyleRes against state-of-the-art inversion methods across various attributes (Pose, Bobcut, Smile) and domains (Cars).

Key Findings:

  • Reconstruction Quality: On CelebA-HQ, StyleRes achieved an FID of 7.04, a significant improvement over FeatureStyle (11.33) and HyperStyle (16.08).
  • Editing Fidelity: StyleRes maintains the highest identity preservation. It is uniquely capable of preserving complex backgrounds, jewelry, and small facial features during significant pose changes.
  • Efficiency: As a single-stage feed-forward network, StyleRes is approximately 3.5x faster than HyperStyle (0.125s vs 0.439s per image), avoiding the iterative refinement steps required by other high-fidelity encoders.

Conclusion

StyleRes effectively resolves the distortion-editability trade-off by treating residual features as dynamic rather than static components. By learning to transform these residuals in tandem with latent space manipulations, the framework achieves high-fidelity reconstruction without sacrificing semantic control. While currently bound by the capabilities of the underlying StyleGAN2 generator, the principle of "transforming residuals" offers a promising path for future generative architectures, including diffusion-based models.

Summary updated

BibTeX
@inproceedings{pehlivan2023styleres,
  author = {Hamza Pehlivan and Yusuf Dalva and Aysegul Dundar},
  title = {{StyleRes: Transforming the Residuals for Real Image Editing with StyleGAN}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2023},
  url = {https://openreview.net/forum?id=9QVB4xopBt},
}
Figure