ReStyle: A Residual-Based StyleGAN Encoder via Iterative Refinement

Yuval Alaluf, Or Patashnik, Daniel Cohen-Or

Introduction

Recently, Generative Adversarial Networks (GANs) have grown in popularity thanks to their ability to synthesize images of high visual quality and diversity. Beyond their phenomenal realism and fidelity on numerous domains, recent works have shown that GANs, e.g., StyleGAN , effectively encode semantic information in their latent spaces . Notably, it has been shown that StyleGAN’s learnt latent space W\mathcal{W} has disentanglement properties which allow one to perform extensive image manipulations by leveraging a well-trained StyleGAN generator. Such manipulations, however, have often been applied to synthetic images generated by the GAN itself. To apply such edits on real images, one must first invert the given image into StyleGAN’s latent space. That is, retrieve the latent code w such that passing w to the pre-trained StyleGAN generator returns the original image. To do so, it has become common practice to invert real images into an extension of W\mathcal{W}, denoted W+\mathcal{W}+ .

Previous works have explored learning-based inversion approaches and train encoders to map a given real image into its corresponding latent code . Compared to per-image latent vector optimization , encoders are significantly faster, as they invert using a single forward pass, and converge to areas of the latent space which are more suitable for editing . However, in terms of reconstruction accuracy, there remains a significant gap between learning-based and optimization-based inversion methods. Hence, while significant progress has been made in learning-based inversions, designing a proper encoder and training scheme remains a challenge with many works still resorting to using a per-image optimization.

Recognizing that obtaining an accurate inversion in a single shot is difficult, we introduce a novel encoder-based inversion scheme tasked with encoding real images into the extended W+\mathcal{W}+ StyleGAN latent space. Unlike typical encoder-based inversion methods that infer the input’s inverted latent code using a single forward pass, our scheme introduces an iterative feedback mechanism. Specifically, the inversion is performed using several forward passes by feeding the encoder with the output of the previous iteration along with the original input image. This allows the encoder to leverage knowledge learned in previous iterations to focus on the relevant regions needed for achieving an accurate reconstruction of the input image. Viewing this formulation in terms of the latent space, our residual encoder is trained to predict the residual, or an offset, between the current latent code and the new latent code at each step. Doing so allows the encoder to progressively converge its inversion toward the target code and reconstruction, see Figure 1. Note also that the inversion is predicted solely using the encoder with no per-image optimization performed thereafter.

In a sense, our inversion scheme, named ReStyle, can be viewed as learning to perform a small number of steps (e.g., 1010) in a residual-based manner within the latent space of a pre-trained unconditional generator. ReStyle is generic in the sense that it can be applied to various encoder architectures and loss objectives for the StyleGAN inversion task.

We perform extensive experiments to show that ReStyle achieves a significant improvement in reconstruction quality compared to standard feed-forward encoders. This is achieved with a negligible increase in inference time, which is still an order of magnitude faster than the time-costly optimization-based inversion. We also analyze the iterative nature of our approach. Specifically, we first demonstrate which image regions are refined at each iterative feedback step demonstrating that our scheme operates in a coarse-to-fine manner. Second, we show that the absolute magnitude of change at each step decreases, with the predicted residuals converging after only a small number of steps.

To demonstrate the generalization of ReStyle beyond the StyleGAN inversion task and its appealing properties compared to current inversion techniques, we continue our analysis by exploring the robustness of our scheme on downstream tasks and special use-cases. To this end, we perform latent space manipulations on the inverted latent codes to see if the embeddings are semantically meaningful. We then explore an encoder bootstrapping technique allowing one to leverage two well-trained encoders to obtain a more faithful translation of a given real image.

Background and Related Works

The idea of employing an iterative refinement scheme is not new. Carreira et al. introduced an iterative feedback mechanism for human pose estimation. Other works have proposed using iterative refinement for optical flow , object pose estimation , object detection , and semantic segmentation among other tasks. To the best of our knowledge, we are the first to adopt an iterative refinement approach for a learned inversion of real images.

The task of GAN Inversion was first introduced by Zhu et al. for projecting real images into their latent representations. In their pioneering work, the authors demonstrate how performing such an inversion enables one to leverage the semantics of the GAN’s latent space for performing various image manipulation tasks. Some works approach this task by directly optimizing the latent vector to minimize the reconstruction error for a given image. These works typically achieve high reconstruction quality but require several minutes per image. Other approaches design an encoder to learn a direct mapping from a given image to its corresponding latent vector. While these methods are substantially more efficient than pure optimization, they typically achieve inferior reconstruction quality. Attempting to balance this trade-off, some works have additionally proposed a hybrid approach and combine the two by using an encoder for initializing the optimization . We refer the reader to Xia et al. for a comprehensive survey on GAN inversion.

2 Latent Space Embedding via Learned Encoders

To perform image manipulations on real images, methods typically follow an “invert first, edit later” approach. There, an image is first embedded into its corresponding latent code, which is then edited in a semantically meaningful manner. Diverging from the above, recent works have proposed end-to-end methods for leveraging the high-quality images generated by GANs for various image-to-image translation and image editing tasks. In these works, a real input image is directly encoded into the transformed latent code which is then fed into the generator to obtain the desired transformed image. By training an encoder with some additional constraint, these works are able to directly solve various tasks without the need for inverting the images beforehand. Other works have explored utilizing features produced by a learned StyleGAN encoder for solving various down-stream tasks such as face verification and layout prediction. These works further emphasize the advantage of training a powerful encoder into the latent space of a pre-trained unconditional generator.

3 Latent Space Manipulation

With the recent advancements in image synthesis through GANs , many works have proposed diverse methods for understanding and controlling their latent representations for performing extensive image manipulations.

Various works use fully-supervised approaches to find latent directions corresponding to various attributes such as age, gender, and expression. On the other end of the supervision spectrum, several methods find directions in a completely unsupervised manner. Others have explored techniques that go beyond a linear traversal of the latent space. Tewari et al. employ a pre-trained 3DMM to learn semantic face edits. Shen et al. learn versatile edit directions through the eigenvector decomposition of the generator weights. Abdal et al. learn non-linear paths via normalizing flows conditioned on a target attribute. Finally, Patashnik et al. utilize CLIP to manipulate images using an input text-prompt. By designing an efficient and accurate inversion method, one is able to leverage these works for manipulating real images.

Preliminaries

Recall that our goal is to train an encoder tasked with inverting real images into the latent space of a pre-trained StyleGAN generator. Let EE and GG denote our encoder and StyleGAN generator, respectively. Given a source image x, our goal is to generate an image y^=G(E(x))\hat{\textbf{y}}=G(E(\textbf{x})) such that y^x\hat{\textbf{y}}\approx\textbf{x}. Observe that in conventional encoder-based inversion methods, the reconstructed image y^\hat{\textbf{y}} is simply computed using a single forward pass through EE and GG via StyleGAN’s latent space representation.

For learning to perform the inversion, these methods introduce a set of losses used to train the encoder network EE on the reconstruction task. For training the encoder, most encoder-based methods employ a weighted combination of a pixel-wise L2 loss and a perceptual loss (e.g., LPIPS ) to guide the training process. Recently, Richardson et al. extend these losses and introduce a dedicated identity loss to achieve improved reconstruction on the human facial domain. To attain improved editability over the inverted latent codes, Tov et al. additionally introduce two regularization losses during training. Observe that during training, the pre-trained generator network GG typically remains fixed.

Method

We now turn to describe our ReStyle scheme and build on the conventional, single-pass encoding approach introduced above. Given an input image x, ReStyle performs N>1N>1 steps to predict the image inversion w=E(x)\textbf{w}=E(\textbf{x}) and corresponding reconstruction y^\hat{\textbf{y}}. Here, we define a step to be a single forward pass through EE and GG. As such, observe that the conventional encoding process, being performed with a single step, is a special case of ReStyle where N=1N=1.

For training the encoder network EE, we define a single training iteration to be a set of NN steps performed on a batch of images. As with conventional encoding schemes, ReStyle uses a curated set of loss objectives for training EE on the inversion task while the pre-trained generator GG remains fixed. Observe that the loss objectives are computed at each forward pass (i.e., step) with the encoder weights updated accordingly via back-propagation (i.e., back-propagation occurs NN times per batch).

During inference, the same multi-step process (without the loss computation) is performed to compute the image inversion and reconstruction. Notably, for a given batch of images, we find that a small number of steps are needed for convergence (e.g., N<10N<10), resulting in fast inference time.

We now turn to more formally describe ReStyle’s inversion process, illustrated in Figure 2. At each step tt, ReStyle operates on an expanded input by concatenating x with the current prediction for the reconstructed image y^t\hat{\textbf{y}}_{t}:

Given the extended 66-channel input xt\textbf{x}_{t}, the encoder EE is tasked with computing a residual code Δt\Delta_{t}, with respect to the latent code predicted in the previous step. That is,

The new prediction for the latent code corresponding to the inversion of the input image x is then updated as:

This new latent wt+1\textbf{w}_{t+1} is passed through the generator GG to obtain the updated prediction for the reconstructed image:

Finally, the updated prediction y^t+1\hat{\textbf{y}}_{t+1} is set as the additional input channels in the next step, as defined by Equation 1.

This procedure is initialized with an initial guess w0\textbf{w}_{0} and corresponding image y^0\hat{\textbf{y}}_{0}. In our experiments, these are set to be the generator’s average style vector and its corresponding synthesized image, respectively.

Observe that constraining the encoder to invert the given image in a single step, as is typically done, imposes a hard constraint on the training process. Conversely, our training scheme can, in a sense, be viewed as relaxing this constraint. In the above formulation, the encoder learns how to best take several steps in the latent space with respect to an initial guess w0\textbf{w}_{0} guided by the output obtained in the previous step. This relaxed constraint allows the encoder to iteratively narrow down its inversion to the desired target latent code in a self-correcting manner. One may also view the ReStyle steps in a similar manner to the steps of optimization, with the key difference that here the steps are learned by the encoder for efficiently performing the inversion.

To show that the presented training scheme can be applied to different encoder architectures and loss objectives, we apply the ReStyle scheme on the state-of-the-art encoders from Richardson et al. (pSp) and Tov et al. (e4e). These two encoders employ a Feature Pyramid Network over a ResNet backbone and extract the style features from three intermediate levels. Such a hierarchical encoder is well-motivated for well-structured domains such as the facial domain in which the style inputs can be roughly divided into three levels of detail. With that, we find such a design to have a negligible impact on less-structured, multi-modal domains while introducing an increased overhead. Moreover, we find that the multi-step nature of ReStyle alleviates the need for such a complex encoder architecture.

We therefore choose to design simpler variants of the pSp and e4e encoders. Rather than extracting the style features from three intermediate levels along the encoder, all style vectors are extracted from the final 16×1616\times 16 feature map. Given a StyleGAN generator with kk style inputs, kk different map2style blocks introduced in pSp are then used to down-sample the feature map to obtain the corresponding 512512-dimensional style input. An overview of the architecture is presented in Figure 3 with additional details and ablations provided in Appendices A.1 and C, respectively.

Experiments

Datasets. We conduct extensive evaluations on a diverse set of domains to illustrate the generalization of our approach. For the human facial domain we use the FFHQ dataset for training and the CelebA-HQ test set for evaluation. For the cars domains, we use the Stanford Cars dataset for training and evaluation. Additional evaluations are performed on the LSUN Horse and Church datasets as well as the AFHQ Wild dataset.

Baselines. Throughout this section, we explore and analyze encoder-based, optimization-based, and hybrid inversion techniques. For encoder-based methods, we compare our ReStyle approach with the IDInvert encoder from Zhu et al. , pSp from Richardson et al. , and e4e from Tov et al. . For optimization-based methods, we compare our results with the inversion technique from Karras et al. . For each of the above encoder-based inversion methods we also perform optimization on the resulting latents for a comparison with hybrid approaches. Additional details can be found in Appendix A.3.

Architecture and Training Details. For the facial domain, we employ the ResNet-IRSE50 architecture from Deng et al. pre-trained for facial recognition. For all other domains, we use a ResNet34 network pre-trained on ImageNet. These networks have a modified input layer to accommodate the 66-channel input used by ReStyle. All results were obtained using StyleGAN2 generators.

Throughout this section, we apply ReStyle on pSp and e4e using the loss objectives and training details (e.g., batch size, loss weights) as originally defined in their respective works. Note that when applying ReStyle, we utilize the simplified encoder architecture presented in Section 4.1 for extracting the image inversion. All ReStyle encoders are trained using N=5N=5 steps per batch.

2 Comparison with Inversion Methods

We first compare ReStyle with current state-of-the-art StyleGAN inversion techniques. While per-image optimization techniques have achieved superior image reconstruction compared to learning-based approaches, they come with a significantly higher computational cost. Therefore, when analyzing the inversion approaches, it is essential to measure reconstruction quality with respect to inference time, resulting in a so-called quality-time trade-off.

Qualitative Evaluation. We begin by showing a qualitative comparison of ReStyle and the alternative inversion approaches across various domains in Figure 4. It is important to emphasize that we do not claim to achieve superior reconstruction quality over optimization. The comparison instead serves to show that ReStyle is visually comparable to the latter. Attaining comparable reconstruction quality with a significantly lower inference time places ReStyle at an appealing point on the quality-time trade-off curve.

With that, we do note the improved reconstruction obtained by ReStyle in comparison with the pSp and e4e encoders, especially in the preservation of fine details. For example in the comparison with pSp (the top three rows), observe the collar of the man in the top left and the hair of the woman in the top right. Similarly, observe the Audi symbol and the license plate in the car comparison on the left-hand side. In the comparison with e4e (the bottom two rows), observe how ReStyle better captures the background of the wild animals and the pose of the horse. A large-scale gallery of results and comparisons is provided in Appendix F.

Quantitative Evaluation. We now perform a quantitative comparison of the inversion approaches across various domains. To measure both pixel-wise and perceptual similarities we apply the commonly-used L2L_{2} and LPIPS metrics. In addition, for the facial domain, to measure each method’s ability to preserve input identity, we measure the identity similarity between the reconstructions and their sources using the CurricularFace recognition method.

To illustrate the trade-off between the different methods we additionally measure each method’s inference time per image. As mentioned, both optimization and ReStyle can be viewed as a continuous curve on a quality-time graph — with each additional step, we attain improved reconstruction quality at the cost of additional inference time.

To provide a complete comparison of all inversion methods, we construct a quality-time graph for each domain. Such graphs can be visualized in Figure 18. To form each graph, we performed the following evaluations for each inversion technique. For each encoder-based inversion, we ran a single forward pass to obtain the reconstruction image, resulting in a single point on the graph. For measuring the optimization technique from , we invert the input image using a varying number of steps from 11 optimization step up to 1,5001,500 steps. For hybrid approaches, given the computed latent codes obtained from the corresponding encoder, we performed optimization with an increasing number of steps between 11 to 500500 steps. Finally, for our two ReStyle encoders, we performed up to 1010 feedback loops.

We begin by analyzing the facial domain. Compared to the conventional pSp and e4e encoders, our ReStyle variants match or surpass their counterparts. More notably, while optimization techniques achieve improved identity similarity compared to ReStyle, they require 20×\approx 20\times more time to match the similarity attained by ReStyle. A similar trade-off can be observed in the cars domain where now the advantage of ReStyle over typical encoders is more pronounced when evaluating the L2L_{2} loss of the reconstructions. In the unstructured churches domain, ReStyle applied over pSp nearly matches both optimization and hybrid techniques in reconstruction quality with a significantly lower inference time. Observe that the first output of ReStyle may be worse than that of a conventional encoder due to the more relaxed training formulation of ReStyle as it is trained to perform multiple steps at inference. With that, ReStyle quickly matches or surpasses the quality of single-shot encoders.

These comparisons point to the appealing nature of ReStyle: although optimization typically achieves superior reconstruction, ReStyle offers an excellent balance between reconstruction quality and inference time. See Appendix E for results on all domains and metrics.

3 ReStyle Analysis

In this section, we explore various aspects of ReStyle to gain a stronger understanding of its behavior and attain key insights into its efficiency. Specifically, we analyze the main details focused on by the encoder at each step and analyze the number of steps needed for convergence during inference. Additional analyses in both the image space and latent space can be found in Appendix B.

Where’s the focus? We begin by exploring which regions of the image are focused on by the encoder at each step during inference. To do so, we consider the human facial domain. For each step tt and each input image x, we compute the squared difference in the image space between the generated images at steps tt and t1t-1. That is, we compute d=ytyt12d=\left\lVert\textbf{y}_{t}-\textbf{y}_{t-1}\right\rVert_{2} where yt\textbf{y}_{t} is defined in Equation 4.

Averaging over all test samples we obtain the average image difference between the two steps. Finally, we normalize the average image to the range $andvisualizetheregionsoftheimagethatincurthemostchangeatthecurrentstepand visualize the regions of the image that incur the most change at the current stept$. We visualize this process in Figure 6 showing ReStyle’s incremental refinements. As can be seen, in the early steps the encoder focuses on refining the background and pose while in subsequent steps the encoder moves its focus to adjusting finer details along the eyes and hair.

In Figure 6 we show only the magnitude of change within each step. That is, the absolute magnitude of change may vary between the different steps. To show that the overall amount of change decreases with each step, we refer the reader to Figure 7. There, all images are normalized with respect to each other allowing one to see how the largest changes occur in the first step and decrease thereafter.

In a sense, the encoder operates in a coarse-to-fine manner, beginning by concentrating on low frequency details which are then gradually complemented by adjusting high frequency, fine-level details.

ReStyle’s iterative progress. We now turn to Figure 9 and show how the reconstruction quality incrementally improves with each additional step of ReStyle. Specifically, observe how ReStylepSp\text{ReStyle}_{pSp} is able to gradually improve the reconstruction of the highly non-frontal input image in the top row. Similarly, notice how ReStylee4e\text{ReStyle}_{e4e} is able to iteratively refine the posture of the horse rider and capture the skewed structure of the church building.

4 Editability via Latent Space Manipulations

Previous works have discussed the importance of evaluating the editability of inversion methods. Here, we show that the editability achieved by ReStyle is comparable to that of the conventional encoders. Since e4e is designed specifically for image manipulations, we choose to show that inversions obtained by combining e4e with ReStyle are still editable. We show visual examples in Figure 8. Compared to e4e, ReStyle is able to better reconstruct the input while still allowing for realistic edits. Notably, observe the more plausible edits over ReStyle’s inversions compared to those obtained via optimization. For example, observe the artifacts in the front bumpers of the car edits when applied over the optimization-based inversions.

5 Encoder Bootstrapping

Finally, we explore a new concept, which we call encoder bootstrapping. To motivate this idea, let us consider the image toonification task in which we would like to translate real face images into their toonified, or animated, version. Pinkney et al. propose solving this image-to-image task by projecting each real input image to its closest toon image in the latent space of a toon StyleGAN obtained via fine-tuning the FFHQ StyleGAN generator. In a similar sense, ReStyle can be applied over pSp to solve this task. Here, ReStyle is initialized with the average toon latent code and its corresponding image. Then, NN steps are performed to translate the image to its toonified version.

With encoder bootstrapping, we take a slightly different approach. Rather than initializing the iterative process using the average toon image, we first pass the given real image to an encoder tasked with embedding real images into the latent space of a StyleGAN trained on FFHQ. Doing so will result in an inverted code w1\textbf{w}_{1} and reconstructed image y^1\hat{\textbf{y}}_{1}. This inverted code and reconstructed image are then taken to initialize the toonification translation using ReStyle. This idea is illustrated in Figure 10. Notice that this technique is possible thanks to the residual nature of ReStyle. By utilizing the FFHQ encoder to obtain a better initialization, we are able to more easily learn a proper residual for translating the input image while more faithfully preserving identity.

We compare several real-to-toon variants in Figure 11. Observe how bootstrapping the toonification process with the FFHQ code results in translations able to better capture the input characteristics and toonify style. Observe the ability of the bootstrapped variant to better preserve make-up, eyeglasses, hairstyle, and expression. In Figure 12, we visualize the inverted real image used to initialize the toonify encoder followed ReStyle’s toonified outputs.

The bootstrapping technique is intriguing as it is not immediately clear why the code in the FFHQ latent space results in a meaningful code in the toonify space. We refer the reader to Appendix D for further analysis.

Conclusions

In our work, we have focused on improving the inversion accuracy of encoders and presented a new scheme for training GAN encoders. Instead of predicting the inversion in one shot, we perform multiple forward passes, which more accurately and quickly converge to the target inversion. In a sense, this scheme allows the encoder to learn how to efficiently guide its convergence to the desired inversion. Moreover, the encoder is trained on a larger, richer set of images consisting not only of the original dataset itself, but also the intermediate reconstructions. We also explored pairing the ReStyle scheme with a bootstrapping technique for the image toonification task. We view this bootstrapping idea and the resulting transformations to be intriguing and may further open the door for additional tasks, leveraging the nature of our residual-based, iterative scheme.

Acknowledgements

We would like to thank Elad Richardson, Omer Tov, Rinon Gal, Ron Mokady, and Yotam Nitzan for their early feedback and discussions. We would also like to thank the reviewers for their insightful remarks and constructive comments. This work was supported in part by the Israel Science Foundation under Grant No. 2366/16 and Grant No. 2492/20.

References

Appendix A Additional Details

We begin by providing additional details regarding the ReStyle encoder architecture presented in Section 4.1. Recall that our simplified architecture is derived from the architecture used in Richardson et al. . There, the authors employ an FPN-based architecture for encoding real images into the StyleGAN latent space. Specifically, the encoder extracts the style input vectors using three intermediate feature maps of spatial resolutions 64×6464\times 64 (for inputs 020-2), 32×3232\times 32 (for inputs 363-6), and 16×1616\times 16 (for inputs 7177-17). Each style vector is extracted from their corresponding feature map using a map2style block, which is a small convolutional network containing a series of 2-strided convolutions with LeakyReLU activations. This FPN-based architecture is illustrated in Figure 13.

With ReStyle, we take a simpler approach. Instead of extracting the style vectors from three intermediate feature maps along the encoder, each style input is extracted from the final 16×1616\times 16 feature map and a map2style block, as illustrated in Figure 3 in the main paper. An ablation study comparing these two architectures is provided below in Appendix C.

A.2 Datasets

Here, we provide additional details regarding the datasets used in each of the evaluated domains.

Human Faces. For the human facial domain, we use all 70,00070,000 images from the FFHQ dataset for training the ReStyle encoders. For evaluations, we use all 2,8242,824 test images from the CelebA-HQ dataset using the official train-test split.

Cars. For the cars domain, we use the Stanford Cars dataset with training performed using the 8,1448,144 training images. For our evaluations, due to the large test set (8,0418,041 images), we randomly select 1,0001,000 images from the test set with all metrics computed using the selected subset.

AFHQ Wild. Here, training and evaluations are performed on 4,7384,738 and 500500 images, respectively, taken from the official AFHQ Wild dataset.

Horses. From the LSUN Horse dataset, we randomly select 10,00010,000 to be used for training and 2,2152,215 images used for evaluations.

Churches. For the churches domain we use all 126,227126,227 training images and 300300 testing images from the official LSUN Church dataset.

A.3 Baselines

In our evaluations in Sections 5.2 and 5.4, we compare ReStyle with various encoder-based inversion methods. Below, we provide additional details on the baselines evaluated in the main paper.

IDInvert. We compared our ReStyle approach to the IDInvert encoder from Zhu et al. on the human facial and cars domains. For the human facial domain, we use the official pre-trained model, which employs a StyleGAN1 generator. For the cars domain, we re-trained IDInvert using an input resolution of 512×384512\times 384 and the official StyleGAN2 generator. Note, due to the long training time required by IDInvert (over three weeks on two NVIDIA P40 GPUs), we chose to train IDInvert only on the cars domain.

pSp. For the human facial domain, we use the official pre-trained model from Richardson et al. . For all other domains, we trained pSp using StyleGAN2 generators and default pSp hyper-parameters. During training, we also incorporated the MOCO-based similarity loss from which was shown to improve reconstruction quality.

e4e. For our comparison with Tov et al. , we trained e4e on the AFHQ Wild dataset using the official implementation and default e4e hyper-parameters. All other domains were evaluated using official pre-trained models.

Appendix B ReStyle Analysis

In this section, we provide additional analyses to complement those performed in the main paper (Section 5.3).

Where’s the focus? (Part II) In Section 5.3 (Figures 6 and 7), we showed which image regions change the most at each inference step and showed how the magnitude of change decreases over time. There, the resulting Figures were obtained by averaging over all 2,000+2,000+ test images. To complement these Figures, we can examine this behavior while observing each image independently rather than averaging over all images. Consider Figure 14. There, we illustrate the intermediate outputs of ReStylepSp\text{ReStyle}_{pSp} alongside the normalized heat-maps where red denotes a large pixel change and blue denotes a small pixel change. As shown, in the early iterations, ReStyle focuses on adjusting global features such as the head pose or the car shape while in subsequent iterations finer details are adjusted.

How many steps are needed? The ReStyle analysis performed in the main paper and above explore ReStyle’s behavior in the image space. Here, we explore the behavior of ReStyle in the latent space. Specifically, we analyze (i) which latent entries change the most across the inference steps and (ii) how many steps are needed for convergence. To do so, we focus on the cars domain and perform the following process. Consider some iteration tt and some latent entry wl\textbf{w}_{l} where l[1,k]l\in[1,k] and kk is the number of style inputs of the generator. To compute how much the values of wl\textbf{w}_{l} change between iterations t1t-1 and tt we compute the squared difference between the latent entries averaged across all test samples.

where wl,t(i)\textbf{w}_{l,t}^{(i)} is the ll-th latent entry of the ii-th sample obtained in iteration tt and vl,tv_{l,t} is the L2L_{2} norm of the average difference dl,td_{l,t}. Having computed the average change of each of the kk latent entries across all test samples, we group the entries into the coarse, medium, and fine inputs as defined by StyleGAN and compute the average change of each group.

In Figure 15, we plot the change along each step for each of the three groups. As can be seen, the coarse input group attains the most change in the early iterations as the encoder focuses on refining the background and pose of the inversions. Conversely, the fine styles undergo the least change and converge after only a few steps, indicating that refining these aspects (e.g., the color) of the output image may be easier for the encoder. Overall, it can be seen that a few number of steps are needed for the encoder to converge to its final inversion prediction. Another interpretation of the above phenomenon is that the learned residuals decrease at every inference step, as is desired.

Appendix C Ablation Study

In this section, we validate our design choices for our ReStyle training scheme and encoder architecture.

The Iterative Training Scheme. We begin by showing that a dedicated iterative training scheme is truly needed. A natural first attempt for creating an iterative inversion scheme is simply using a pre-trained conventional encoder and passing the output image back as input multiple times. Notice that there are key differences between the above formulation and the ReStyle formulation. First, in the ReStyle scheme, we pass both the input and current output to the encoder. Second, a ReStyle encoder is trained explicitly to output a residual with respect to the previous latent at each step.

In Figure 16 we provide a comparison on the human facial and cars domains using both a pSp encoder and e4e encoder trained using the ReStyle formulation and naive formulation presented above. As can be seen, at each additional step, the naive formulation moves away from the reconstruction of the input image. This shows that our dedicated iterative, residual-based training scheme is indeed needed over readily-available encoders.

The ReStyle Encoder Architecture. Here, we show that our simplified encoder architectural design choice leads to a negligible difference in reconstruction quality while reducing the inference time compared to the FPN-based architecture from Richardson et al. . Table 1 summarizes the reconstruction results across 55 domains. For each domain and encoder, we perform 55 steps during inference and display quantitative results computed on the final output. As shown, the two variants attain nearly identical reconstruction quality in terms of both L2L_{2} and LPIPS similarity. However, our simplified architecture is more than 10%10\% faster.

Appendix D Analyzing the Toonify Latent Space

In Section 5.5, we explored a new encoder bootstrapping technique for performing image toonification . Rather than initializing ReStyle using the average latent code and corresponding toon image, the iterative process is initialized by first inverting the real image into the FFHQ StyleGAN latent space. The inverted code and reconstructed image are then used to initialize the ReStyle toonify encoder. Thanks to the improved initialization from the initial inversion, the toonify encoder is able to learn a more faithful translation of the real image into its corresponding toon image. However, it is not trivial to assume that the real inverted code in the FFHQ latent space corresponds to the same identity characteristics in the toonify latent space.

To show that the above is in fact true we randomly sample w vectors from the FFHQ latent space. We then pass the same w vector to both the FFHQ StyleGAN generator and toonify StyleGAN generator to see if the synthesized images are semantically similar. We provide several examples in Figure 17. As shown, the same latent code produces semantically similar images in both latent spaces, indicating that the two latent spaces are indeed well-aligned. As a result of the above, we gain valuable insights as to the effectiveness of the encoder bootstrapping technique in the task of image toonification.

Appendix E Quantitative Results

In Section 5.2, we quantitatively compared various inversion methods by constructing quality-time graphs which allowed us to visualize how reconstruction quality changes with respect to inference time. In Figures 18 and 19 we provide the quality-time graphs for both the L2L_{2} and LPIPS loss metrics across all five domains. For the human facial domain we additionally measure the identity similarity of the reconstructed images by using the Curricularface method for facial recognition.

Appendix F Additional Results

The remainder of this document contains additional comparisons and results, as follows:

Figures 20 and 21 contain additional comparisons on the human facial domain. Additionally, Figure 22 provides a comparison on more challenging input poses and expressions.

Figures 23 and 24 contain additional comparisons on the cars domain.

Figures 25 and 26 contain additional comparisons on the churches domain.

Figure 27 contains additional comparisons on the wild animals domain.

Figure 28 contains additional comparisons on the horses domain.

Figure 29 contains comparisons to the IDInvert encoder from Zhu et al. on the human facial and cars domains.

Figure 30 shows iterative outputs generated by ReStyle applied over pSp on the human facial domain.

Figure 31 shows iterative outputs generated by ReStyle applied over e4e on the cars domain.

Figure 32 shows iterative outputs generated by ReStyle applied over pSp on the churches domain.

Figure 33 shows iterative outputs generated by ReStyle applied over e4e on the horses domain.

Figures 34 contains editing comparisons with the optimization technique from Karras et al. on the human facial domain obtained using InterFaceGAN .

Figures 35 contains editing comparisons with the optimization technique from Karras et al. on the cars domain obtained using GANSpace .

Figures 36 contains editing comparisons with the optimization technique from Karras et al. on the horses domain obtained using SeFa .

Figures 37 and 38 contain additional results on the image toonification task using the encoder bootstrapping method presented in Section 5.5.

Note, all results are shown at full-resolution: 1024×10241024\times 1024 for human faces, 512×512512\times 512 for cars and wild animal faces, and 256×256256\times 256 for churches and horses.