Source-linked AI summary
Improved StyleGAN Embedding: Where are the Good Latents?
Peihao Zhu, Rameen Abdal, Yipeng Qin, John Femiani, Peter Wonka
TL;DR
StyleGAN inversion seeks codes that reconstruct input images while remaining suitable for editing, but high-capacity W+ inversion can yield codes in low-density regions. The paper analyzes latent distributions in P_N space and introduces a regularizer based on that analysis; it reports a better reconstruction–editing trade-off and stronger downstream-application results than competing methods.
Problem
StyleGAN embeddings must reconstruct input images while supporting realistic edits, yet unregularized W+ inversion can find codes in low-density regions associated with undesirable manipulations.
Source: §1 · p. 1Method
The paper analyzes latent-code locations in P_N and P+_N spaces and regularizes embeddings toward the P_N origin, where training W codes are densest.
Source: §1 · pp. 1–2Results
Takeaways & Limitations
The authors report that switching to P_N space can significantly help follow-up work analyzing and improving StyleGAN embedding.
Source: §6 · p. 8The work does not investigate correlations among the 18 components of extended latent codes, and experiments did not show consistent improvement from the tested similarity regularizers.
Source: §6 · p. 8
Abstract
from arXiv · showhide
StyleGAN is able to produce photorealistic images that are almost indistinguishable from real photos. The reverse problem of finding an embedding for a given image poses a challenge. Embeddings that reconstruct an image well are not always robust to editing operations. In this paper, we address the problem of finding an embedding that both reconstructs images and also supports image editing tasks. First, we introduce a new normalized space to analyze the diversity and the quality of the reconstructed latent codes. This space can help answer the question of where good latent codes are located in latent space. Second, we propose an improved embedding algorithm using a novel regularization method based on our analysis. Finally, we analyze the quality of different embedding algorithms. We compare our results with the current state-of-the-art methods and achieve a better trade-off between reconstruction quality and editing quality.
1 INTRODUCTION
StyleGAN embedding must balance faithful reconstruction against the realism of subsequent edits. The paper analyzes where good latent codes lie and uses that analysis to regularize embeddings and evaluate methods across reconstruction and downstream tasks.
1 INTRODUCTION
- Embedding methods must balance similarity to the input image against visual quality and realism after latent-space edits.The cited examples include pose, lighting, and age edits.Source: §1 · p. 1
- W and Z codes lack the expressiveness of W+ for representing real-world faces, while W+’s added degrees of freedom make unregularized inversion ill-conditioned.Such inversion can place codes in low-density regions that are not normally reached by the mapping network, leading to undesirable manipulated images.Source: §1 · p. 1
- In P_N space, latent-code quality relates closely to distance from the center: reconstruction favors greater distance, whereas editing favors proximity.The space approximates the latent-code distribution as multivariate normal, and its L2 norm is a Mahalanobis distance that biases embeddings toward denser regions.Source: §1 · p. 1
- The proposed regularizer draws embeddings toward the origin, where training W codes are densest, and extends to a corresponding W+ regularizer.It controls distance without preventing optimization from reducing reconstruction error; its hyperparameter tunes the reconstruction–editability trade-off, with a smaller reconstruction penalty than a constraint.Source: §1 · pp. 1–2
- The paper contributes P_N and P+_N spaces, a regularizer intended to improve the reconstruction–editing trade-off, and a broad evaluation of embedding methods.The evaluation includes downstream edits and conditional tasks such as super-resolution, colorization, and inpainting.Source: §1 · p. 2
2 RELATED WORK
Related embedding work builds on StyleGAN and seeks a balance between reconstruction and editing. Prior approaches make different trade-offs through latent-space choice, staged optimization, or constraints on the set of good latents.
2 RELATED WORK
- StyleGAN became a common basis for GAN image embedding because of its visual quality and comparatively lightweight architecture, while Image2StyleGAN first proposed embedding images into its W+ space.The cited StyleGAN works are [Karras et al. 2020a, 2019, 2020b], and Image2StyleGAN is [Abdal et al. 2019].Source: §2 · p. 2
- Embedding methods trade reconstruction against editing: I2S++ favors reconstruction in W+, while StyleGAN2 favors editing in W, and PIE stages W embedding before W+ optimization.Encoder-based methods also use an initial encoding followed by optimization; using only the encoder yields poor reconstruction.Source: §2 · p. 2
- PULSE searches a manifold of good latents but constrains codes to a hypersphere subset, which the paper associates with poorer reconstruction; the authors propose analysis and an algorithm that outperform existing methods.PULSE is cited as.Source: §2 · p. 2
3 WHICH SPACE TO USE: A STATISTICAL ANALYSIS OF LATENT DISTRIBUTIONS
The analysis compares latent spaces to find a tractable model of StyleGAN codes and a useful basis for regularization. It motivates whitening P-space into PN-space, then extending that analysis to P+N for W+ embeddings.
W-space and P-space
- W-space marginal distributions are heavily skewed; the authors transform W to P by inverting the mapping network’s final LeakyReLU, whose dimensions appear Gaussian-like but remain statistically dependent.Multivariate normality tests reject P-space normality at 5% significance.Source: §3 · p. 2
P-space distribution
- Although 219 of 512 P-space marginal distributions pass the Mardia normality test at 5% significance, the joint distribution is not normal, is unimodal and correlated, and has compact support.The authors use this Gaussian-like structure to motivate PN-space, while noting that the MLP mapping network prevents a true normal distribution.Source: §3 · pp. 2–3
PN-space
- Whitening P-space produces isotropic PN-space, where the L2 norm corresponds to Mahalanobis distance and regularization biases embeddings toward the mode, especially along low-variance directions.Unlike shifting codes toward the origin in W+, Mahalanobis regularization preserves components with high variation in the training corpus.Source: §3 · pp. 3–4
Regularization and reconstruction
- Regularization in P+N keeps the density loss low with little effect on reconstruction, while omitting it lets the latent norm grow arbitrarily large.In low-density regions, edits may also remain low-density and be perceived as low quality or unrealistic.Source: §3 · p. 4
PN-space validation
- PN-space sampling yields FID 3.28 versus StyleGAN2’s 2.81, while fitting and sampling a normal distribution in W-space yields FID 76.63; PN-space is nevertheless too restrictive for embedding.Source: §3 · p. 4
P+N-space
- The analysis extends PN-space to P+N by transforming each of the 18 W+ layer codes, enabling analysis and regularization of StyleGAN inversion algorithms.Source: §3 · p. 4
4 IMPROVED I2S
The reconstruction setup combines perceptual and pixel losses with regularization in P+N-space. The implementation uses a fixed optimizer, learning rate, and step count for all images.
4.1 Reconstruction Losses
- Using LPIPS improves noticeably over VGG-perceptual loss, with bicubic downsampling for generated images and Lanczos for reference images outperforming bicubic for both.Lanczos is not differentiable, so the authors do not use it for both images.Source: §4.1 · p. 4
- The reconstruction loss combines LPIPS with pixel-wise L2 loss, while a hyperparameter controls regularization of P+N codes away from the center.Source: §4.1 · p. 5
4.3 Implementation Details
- All images use 1,300 optimization steps at learning rate 0.01 with ADAM and standard settings.Source: §4.3 · p. 5
5 EVALUATION
The evaluation compares II2S with selected embedding methods across reconstruction, editing, and conditional tasks, supplemented by user studies and latent-distribution analysis. Results examine its reconstruction–editing trade-off and the effect of regularization.
5 EVALUATION
- The evaluation uses 120 Unsplash images not used to train StyleGAN2 and compares II2S with selected methods, including updated I2S and PULSE baselines.The comparison includes I2S, PULSE, StyleGAN2, StyleGAN2Encoder, and pSp.Source: §5 · p. 5
5.1 Reconstruction Quality
- With λ=0.001, II2S and I2S rank first or second on all reconstruction metrics except SSIM; at λ=0.005, users accept II2S more than any method except I2S.The authors recommend λ=0.005 as the best reconstruction–editing compromise.Source: §5.1 · p. 5, Table 1 · p. 5
5.4 User Studies
- II2S edits are preferred across tasks, and it outperforms competing methods on most user-study comparisons; only two competitors beat it on any task.The pSp preference for age editing was not statistically significant.Source: §5.2 · p. 5, §5.4 · p. 8, Table 2 · p. 8
5.2 Editing Quality
- Fig. 6 shows that no method handles specular reflections; I2S reconstructs most accurately, while increasing λ can trade some accuracy for realism.For the nose-ring outside the GAN space, I2S generates an artifact that II2S does not.Source: Figure 6 · p. 6
5.3 Conditional Embedding Quality
- II2S results lead in colorization and inpainting user judgments and beat I2S and PULSE on super-resolution, while its advantage over pSp there is not significant.Inpainting covers half the image, and II2S loses only to ground truth; pSp comparisons for colorization and inpainting were unavailable because task-specific encoders were not provided.Source: §5.3 · p. 7, Figure 8 · p. 7
5.4 User Studies
- Each user-study task received 120 responses with presentation order reversed; preferences below 40% or above 60% were significant at 95% confidence.Participants chose the image that best accomplished the task with the fewest artifacts.Source: §5.4 · p. 7
5.5 Ablation Study
- The authors selected λ=0.005 for all tests based on average user responses, as a trade-off between reconstruction and editing quality.They compared λ settings of 0.01, 0.005, and 0.001.Source: §5.5 · p. 8, Table 3 · p. 8
5.6 Histogram of the Embeddings
- High-learning-rate I2S overfitting coincides with wider, higher-variance, outlier-rich P+N histograms; pSp and S2E have the lowest variance.The authors conjecture that narrow histograms correlate with underfitting; SG2's high variance may reflect fewer unique samples.Source: §5.6 · p. 8, Figure 9 · p. 8
6 LIMITATIONS, FUTURE WORK, AND CONCLUSION
The paper introduces P_N space for analyzing StyleGAN embeddings and reports a regularizer that balances reconstruction and editing quality. Its evaluation favors the method on downstream applications, while correlations among extended-latent components remain for future work.
6 LIMITATIONS, FUTURE WORK, AND CONCLUSION
- Correlations among the 18 extended-latent components were not investigated, and tested regularizers did not yield consistent improvement.The authors leave this question for future work.Source: §6 · p. 8
- The evaluation reports that the authors’ results clearly outperform competing methods for downstream applications.The paper also describes its evaluation as extensive.Source: §6 · p. 8
- P_N space supports embedding analysis, and the proposed regularizer offers a trade-off between reconstruction quality and editing quality.The paper presents the regularizer as part of its improved StyleGAN embedding method.Source: §6 · p. 8
A.1 Comparison of Editing Quality
The appendix evaluates editing across pose, age, lighting, gender, and eyeglasses, using StyleFlow and a separate GANSpace pose experiment. The authors report the strongest overall editing results for their method, but note that GANSpace edit strength varies with the embedding.
A.1 Comparison of Editing Quality
- StyleFlow is the main editing evaluation method, while the pose experiment also uses GANSpace edits at five coordinate values from -2σ to +2σ.The GANSpace values are -2σ, -σ, 0, σ, and +2σ.Source: §A.1 · p. 9
- Editing quality is tested on pose, age, lighting, gender, and eyeglasses, with fixed targets for all except the input-dependent gender swap.The pose target is 20° yaw, age target is 50, and the lighting direction points toward the viewer’s right.Source: §A.1 · p. 9
- The authors report their method has the best overall editing results; pSp is slightly better in two edits but clearly worse in two others.Table 4 presents the quantitative editing-quality comparison.Source: §A.1 · p. 9, Table 4 · p. 10
- GANSpace pose metrics are not conclusive, and edit strength depends strongly on the initial embedding and embedding method.The reported table observes stronger reactions for the authors’ method and pSp than for other methods.Source: Table 5 · p. 10, §A.1 · p. 10
A.2 Linear Interpolation
The appendix assesses semantic interpolation by measuring FID on interpolations between embedded images. The reported quantitative results are best together with I2S, but the metric uses a smaller sample and is not conclusive.
A.2 Linear Interpolation
- Interpolation is tested with FID on 2,500 generated interpolated images from 500 dataset image pairs, with five interpolation proportions per pair.The dataset contains 120 images, and the interpolation proportions are 0.1, 0.25, 0.5, 0.75, and 0.9.Source: §A.2 · p. 10
- For linear interpolation, the method has the best quantitative results together with I2S, though FID uses 2,500 rather than 50,000 images and is not entirely conclusive.Several other authors also report FID on smaller image sets for editing and manipulation tasks.Source: §A.2 · p. 10
- P+N is a nonlinear mapping from W+ used as a regularizer and may negatively impact entanglement; the qualitative results are described as having the best reconstruction quality.The passage distinguishes that reconstruction-quality observation from the interpolation FID comparison.Source: §A.2 · p. 10
A.3 Style Mixing
Style mixing is used to assess whether embeddings support combining styles across StyleGAN layers. The authors report the best results for their method, while noting that the FID comparison uses only 500 images and must be considered alongside reconstruction quality.
A.3 Style Mixing
- Style mixing and structural edits both reflect how well a latent separates style and content across StyleGAN layers.The appendix motivates style mixing as a check of whether an embedding supports high-quality mixing.Source: §A.3 · p. 10
- The experiment combines the first 7 layers from one image with the remaining 11 layers from another and evaluates FID against the original images.The appendix reports the results in Table 6.Source: §A.3 · p. 10, Table 6 · p. 10
- The authors report the best style-mixing results for their method, but the FID comparison uses only 500 images and should be considered alongside reconstruction quality.Qualitative results are shown in Fig. 17.Source: §A.3 · p. 10, Table 6 · p. 10
B ABLATION STUDY
The ablations find that LPIPS matters more than the downsampling choice, while embedding in Z+ produces worse results than W+. The accompanying examples show how the regularizer and embedding choices affect editing, stability, and fine details such as eyes.
B ABLATION STUDY
- Embedding in Z+ yields clearly worse results than W+, with artifacts in several embedded images.The quantitative comparison is in Table 7; the regularizer hyperparameter λ is 0.001.Source: B ABLATION STUDY · p. 10, Table 7 · p. 10
- Replacing VGG with LPIPS leads to significant differences, while the downsampling operation has a very minor effect.The comparison is presented with quantitative results in Table 8 and qualitative results in Fig. 12.Source: B ABLATION STUDY · p. 10, Table 8 · p. 10, Figure 12 · p. 11
C LOOKING AT THE “EYES” AND “MOUTH”
- The examples show edits tending to preserve identity and non-edited attributes, while retaining realism even at extreme poses.The pose comparison notes preserved nose position and iris shape at extreme poses relative to I2S.Source: Figure 10 · p. 11, Figure 11 · p. 11
- Because per-image iteration tuning for I2S is impractical, the authors stress checking eyes and teeth for overfitting and poor editing quality.They show that their regularizer can prevent overfitting, making a difference for eyes and teeth.Source: C LOOKING AT THE “EYES” AND “MOUTH” · pp. 11–12
- Without the P+N regularizer, the generator cannot preserve pupil and iris shapes in the W+ embedding.The regularized result applies the regularizer in P+N space to a W+ embedding.Source: C LOOKING AT THE “EYES” AND “MOUTH” · p. 12, Figure 14 · p. 12
D VISUAL EXPLANATION OF THE PULSE REGULARIZER PROBLEM
Repeated embeddings with the PULSE regularizer can vary substantially because its random initialization and projection location influence the result. The figures contrast that behavior with interpolation examples and distinguish the latent space used to find codes from the space recommended for intuitive edits.
D VISUAL EXPLANATION OF THE PULSE REGULARIZER PROBLEM
- PULSE can produce widely different embeddings of the same image because its random initialization and initial projection location influence the final result.The authors describe its projection onto a subset of latent space as unnecessarily restrictive, despite that subset's high quality.Source: D VISUAL EXPLANATION OF THE PULSE… · p. 12
- The W+ interpolation examples show high-quality endpoint reconstructions and plausible intermediate images.The figure illustrates two linear interpolations, from column one to five and from five to ten.Source: Figure 15 · p. 13
- P+N space helps find latents in dense mapping-network regions, while W+ is the more intuitive space for edits.The P+N examples show linear interpolations, but the authors do not recommend performing edits in that space.Source: D VISUAL EXPLANATION OF THE PULSE… · p. 14, Figure 16 · p. 14
- The style-mixing figure presents examples of style mixing.Source: Figure 17 · p. 15
- In the I2S progression, the eyes lose realism by 800 iterations.The original image appears to the left of the progression.Source: Figure 18 · p. 16
- The PCA figure compares marginal and pair-wise Bernoulli distributions before and after PCA, showing only the first two post-PCA dimensions.Source: Figure 19 · p. 16
Related papers
This paper cites
- Very Deep Convolutional Networks for Large-Scale Image Recognition2014
- The Unreasonable Effectiveness of Deep Features as a Perceptual Metric2018
- Progressive Growing of GANs for Improved Quality, Stability, and Variation2017
- Analyzing and Improving the Image Quality of StyleGAN2019
- Encoding in Style: a StyleGAN Encoder for Image-to-Image Translation2020
- GANSpace: Discovering Interpretable GAN Controls2020