ReStyle: A Residual-Based StyleGAN Encoder via Iterative Refinement
Paper · 2021 · Yuval Alaluf, Or Patashnik and Daniel Cohen‐Or
Summary
To edit a photograph with StyleGAN, you first need a set of controls that makes the generator produce something close to that photograph. Finding those controls is called inversion. A trained encoder can estimate them quickly, but its reconstruction can miss details that matter to the person making the edit. Searching for a better fit separately for each photograph usually improves the reconstruction at a substantial cost in time. ReStyle asks whether an encoder can recover more of those details by looking at what its own first attempt got wrong.
ReStyle begins with the image made from StyleGAN’s average style code. At each pass, the encoder sees the original image alongside the latest reconstruction. It predicts a correction to the current code, and the fixed generator renders the corrected code so the encoder can inspect the result on the next pass. The authors train the encoder to work through this sequence, supervising the reconstruction at every pass. They apply the same procedure to encoders based on pSp and e4e, with a simpler architecture for producing the generator’s style inputs.
The experiments cover human faces, cars, wild animals, churches, and horses. ReStyle can start behind a conventional encoder and recover the difference over subsequent passes. It matches or exceeds its conventional counterparts in the reported face comparison, and the car comparison shows a clearer advantage in pixel error. Optimization can reach higher reconstruction quality. In the face timing comparison, it takes ≈ 20× as long to match the identity similarity reached by ReStyle. The authors also trace what changes between passes. Early corrections in portraits tend to affect pose and background, while later changes concentrate on finer features such as eyes and hair.
The code also has to remain useful after reconstruction. The paper shows examples in which ReStyle applied to e4e preserves enough of the source to improve the starting image and still supports plausible changes to a face, car, or horse. A separate experiment uses a real-face inversion to initialize the translation of that face into a cartoon. In the examples, this gives the cartoon a better chance of retaining features such as the person’s glasses or expression. Together, the tests show how feedback can improve the starting point for an edit and how an informed starting point can help the same feedback procedure with translation.
Deep dive: ReStyle: A Residual-Based StyleGAN Encoder via Iterative Refinement
ReStyle trains a StyleGAN encoder to correct its own reconstructions, improving image inversion in a few passes while keeping the result editable. · about 32 minutes to read
The problem and its context
An image that the generator can work with
StyleGAN is a generative adversarial network, or GAN, for image synthesis. The part used for inversion is the generator, which takes numerical inputs and turns them into an image. In the paper’s setting, the generator is unconditional. It has learned to produce images in a domain such as faces or cars, and its normal input is a code instead of a photograph supplied as a target. Codes live in a latent space, a space of numerical representations that are internal to the image synthesis procedure. Moving to another code changes the resulting image.
The appeal of StyleGAN for editing comes from the structure of that space. As the authors recount, earlier studies found directions of movement that tend to correspond to recognizable changes. Moving along a direction may change a face’s apparent age or expression, for example. A direction is useful when it changes the intended attribute while leaving enough of the other content intact for the edit to read as a change to the same subject. The paper refers to this partial separation of attributes as disentanglement.
An image originally synthesized by a generator already has a code that can serve as the starting point for such an edit. For a photograph, the starting point has to be estimated. Inversion tries to find a code whose generated image resembles that photograph. A poor approximation can alter the subject’s identity, change a pose, or lose a small feature before an edit has even begun. All of those discrepancies then become part of the image that the editor is working with.
In this setting, calling the task an inversion describes the direction of the calculation. Generation starts with a code and produces pixels. Inversion starts with pixels and tries to recover a useful code. The practical target is a good representation of the photograph within the generator’s range. A comparison between the source and the reconstruction can tell us something about that representation even when there is no known code to use as a reference answer.
Why the choice of latent space matters
The paper distinguishes StyleGAN’s learned style space, W, from the extended space W+. A StyleGAN generator takes style inputs at different points in its synthesis process. The extended space allows those inputs to have their own style vectors. The encoder can therefore describe a source using a collection of vectors, with a separate entry for each style input to the generator. The paper follows earlier inversion work in adopting this representation. Image2StyleGAN
That flexibility addresses a practical concern. A user may care about matching both the arrangement of the subject and small visual particulars. Separate style inputs give the inversion more freedom to seek a fit. For an editing application, though, a good fit and a good place from which to make a change are separate properties. A code can give a close reconstruction while responding poorly to a particular edit. Conversely, a representation that works well with a familiar edit direction can still omit something important in the original image. This is why the paper examines reconstructions and edited images separately.
The established approaches to inversion
The paper traces GAN inversion for real-image manipulation to earlier work by Zhu and colleagues. One approach searches directly over possible codes for each image. It renders a candidate, compares that rendering with the target, and uses the reconstruction objective to guide the next update. The image remains the same throughout this search. What changes is the candidate code. Given enough time, the search can give a close fit. The authors describe earlier optimization methods as typically taking several minutes for an image.
A learned encoder moves much of this work to training. During use, the encoder takes an image and predicts a code in a forward pass, a calculation that runs its input through the trained network. The generator then takes the code and creates the reconstruction. This route is much faster per image. The paper also notes prior findings that learned encoders can land in parts of the latent space that are better suited to editing. Their challenge is reconstruction accuracy, particularly when a single prediction has to account for both the image’s overall structure and its local details.
Hybrid methods use an encoder’s prediction to start a per-image search. The encoder supplies a candidate that already carries information about the target, and the optimizer adjusts it according to the reconstruction objective. The two stages have distinct roles. A learned mapping provides the starting point, and an image-specific optimization procedure does the subsequent work. This gives the authors a useful baseline for ReStyle. A fair timing comparison has to consider what a search can do with a good starting point as well as what it can do on its own.
The paper also distinguishes inversion followed by editing from end-to-end image translation. In the former, the code first represents the source image, and a subsequent operation changes it. In the latter, an encoder is trained to produce a code for the desired transformed image directly. The generator’s rendering can thus be a translation from the outset. Work cited by the authors uses additional training constraints to obtain such outputs. Other studies use features produced by a StyleGAN encoder for downstream tasks such as face verification or layout prediction. Both lines of work motivate learning to extract useful representations from a generator that was originally trained for image synthesis.
Feedback as a way to revise a prediction
ReStyle draws on an idea the authors identify in other areas of computer vision. A system can make an initial prediction, examine information about that prediction, and then revise it. The paper points to human pose estimation as an example of iterative error feedback and also mentions work on optical flow, object localization, and semantic segmentation. The common design question is how to make an earlier output informative to the next prediction.
For image inversion, the object to revise is a code. Its most readily interpretable consequence is the image it produces. An encoder that sees the source and that rendered image can respond to the visible discrepancy between them. This makes the fixed generator part of the feedback loop. Each candidate code can be assessed through its own rendering before the encoder proposes another change. The inversion problem remains the same, but it can now be approached as a sequence of corrections with access to evidence produced along the way.
The method, step by step
What the encoder sees on each pass
Consider a photograph of a face whose head is turned. The average StyleGAN image gives the procedure a place to start, even if its pose and appearance are a poor match for the photograph. The encoder sees both images and predicts a change in the generator’s style controls. When the changed controls are rendered, the resulting face may be closer in pose. The next pass then gets a more informative starting image. It can address discrepancies that are easier to see once the head is in approximately the right position. This example describes how the loop can be used. The encoder learns its own allocation of work across passes from the training objective.
The target photograph remains visible throughout. The generated companion image changes on every pass, and the code behind it is carried forward. The encoder receives images as its input. The process uses the stored code separately, adding the encoder’s output to it. Both parts of the state matter. The picture gives the encoder evidence of the current fit, while the code gives the correction something to act on.
A residual here means the change that should be made to the current code. It lives in W+, the same space as the code being corrected. The encoder can therefore make a change to the style vector for one generator input while making different changes to others. The residual is distinct from the image discrepancy that motivates it. A difference visible at a particular location in a photograph does not itself specify which style input to change. The encoder learns how to turn visual evidence into a change that works through the generator.
How ReStyle refines an inversion
The steps in order.
From a single prediction to a recurrent update
The usual encoder formulation starts with an image and predicts its representation directly. The generator renders the result.
ŷ = G(E(x))
Here x is the source image, E is the encoder, and E(x) is the code predicted for that image. G is the fixed StyleGAN generator and ŷ is the reconstruction. The equals sign defines the reconstruction through the composition of those two operations. Training seeks a reconstruction close to x according to the chosen image losses.
ReStyle starts with w₀, the initial code, and ŷ₀, its corresponding image. The subscript ₀ denotes the initialization before any learned correction is made. For ordinary inversion in the experiments, the authors take the generator’s average style vector as the starting point and use the image synthesized from it as the initial reconstruction. That reconstruction gives the first call to the encoder the same kind of visual input as subsequent calls, even though it comes from the initialization.
At a step indexed by t, the authors first join the original image with the current reconstruction.
xₜ := x ∥ ŷₜ
The symbol x denotes the unchanged source, and ŷₜ denotes the current reconstruction at index t. The operator ∥ means concatenation along the image channels, and := defines xₜ as the resulting input to the encoder. The paper describes this as a 6-channel input. The source and reconstruction occupy separate channels, so the encoder can use their appearance as well as differences between them.
Next the encoder predicts the correction.
Δₜ := E(xₜ)
Here Δₜ is the latent residual predicted at index t. E is the encoder used throughout the sequence, and xₜ is the joined image input just defined. The symbol := gives the value of Δₜ. The residual has the structure of a W+ code, so its elements correspond to elements of the current style estimate.
The procedure adds the correction to the stored estimate.
wₜ₊₁ ← Δₜ + wₜ
The symbol wₜ is the current code, and wₜ₊₁ is the code after the update. The index t refers to the current state, and t + 1 refers to the next state. The plus sign adds the residual Δₜ to the current code in their shared latent space. The left arrow indicates that the resulting value becomes the new estimate. This addition is what lets the next pass build on the code reached so far.
Finally the generator turns the new estimate into the next image.
ŷₜ₊₁ := G(wₜ₊₁)
The symbol ŷₜ₊₁ is the updated reconstruction, G denotes the generator, and wₜ₊₁ is the updated latent code. The definition symbol := assigns the generator output to ŷₜ₊₁. The next pass pairs that image with x again. As the loop proceeds, the code and the reconstruction advance together, with the reconstruction giving a view of what the current code does.
The paper uses N for the total number of steps in a run and defines a step as a forward pass through the encoder and generator. In its description, setting N to 1 is the single-step case. A ReStyle encoder trained for several passes can still return a result after its opening pass, but that result comes from a training regime in which more corrections are expected. This distinction matters when comparing it with an encoder trained expressly to complete the task in a single prediction.
How the correction procedure is learned
The generator is pretrained and kept fixed. The encoder’s job is to learn which code changes produce better reconstructions through that generator. Each training batch goes through a sequence of steps on the same source images. At each step, the encoder sees the current reconstructions, predicts residuals, and obtains new generated images. The reconstruction objectives are evaluated at that step, and the encoder’s weights are updated by back-propagation. This is the calculation that uses the loss to determine how the encoder’s parameters should change. The paper describes a parameter update at each forward step, giving N back-propagations per batch.
The losses give the method a target even though a hand-labelled style code is unavailable for a real photograph. Pixel-wise L2 penalizes differences at corresponding image positions. A perceptual loss such as LPIPS compares the images through learned feature representations. The paper explains that encoder objectives commonly combine those kinds of loss, and that pSp adds an identity objective for human faces. It also describes e4e’s regularization objectives as a way to promote editability. Regularization here means constraints included in training to shape the kinds of latent representations the encoder produces. The experiments carry over the loss objectives and training settings of the respective encoder approaches when applying ReStyle.
All the ReStyle encoders are trained with N = 5 steps per batch. A batch therefore supplies the encoder with more than the original set of source images. It also supplies intermediate renderings, the very kinds of imperfect reconstructions the encoder will encounter when deployed. These renderings change with the quality of the current estimate. The same photograph can be paired with a poor approximation early in the sequence and a visibly closer one later. Training gives the encoder practice correcting states that arise from its own predictions.
At inference, the sequence of rendering and correction still runs. The loss evaluation and weight updates belong to training. Once the encoder has been trained, its current correction comes from evaluating the network on the paired images. In that sense the forward passes take the place of steps in a per-image search. They retain the ability to respond to the individual target and its current reconstruction, while the rule for choosing an update has already been learned. The final code can go straight to a subsequent editing operation.
How the encoder produces the style vectors
The authors implement the scheme using pSp and e4e as their starting points. Their original architectures use a ResNet backbone and a Feature Pyramid Network, abbreviated FPN. The backbone produces image features, and the pyramid supplies feature maps at different spatial resolutions. Different style inputs can then be derived from different levels. A feature map is an array of responses organized over image locations. Higher and lower resolutions give the style heads access to representations at different spatial scales.
In the original architecture described in the appendix, the feature map at 64 × 64 supplies style inputs 0 − 2, the one at 32 × 32 supplies inputs 3 − 6, and the map at 16 × 16 supplies inputs 7 − 17. The paper explains the motivation through faces, where the effects of style inputs can be grouped approximately by level of detail. The encoder can give separate groups of style vectors access to feature maps suited to different scales of the image.
ReStyle’s simplified version takes all its style vectors from the final 16 × 16 map. Given a generator with k style inputs, the encoder uses k map2style blocks, where k is the number of inputs that must receive a vector. Each block converts the shared spatial features into its own 512-dimensional vector. The map2style design comes from pSp and uses strided convolutions to reduce spatial dimensions, with LeakyReLU activations. A shared feature map still leads to separate output vectors because each style input has a dedicated block. In ReStyle, those vectors form the residual.
The authors motivate the simpler architecture in part by the cost of computing and using pyramid features on every pass. The tests also include domains with less consistent arrangements than human portraits. They argue that those settings give less reason to assume that a particular style input should always draw on a particular level of a feature pyramid. With iterative correction, the network can also address different scales of discrepancy as the state changes. The paper tests the architectural choice separately by running ReStyle with the pyramid and with the final-map design.
The face experiments use ResNet-IRSE50 pretrained for face recognition. The other domains use ResNet34 pretrained on ImageNet. In each case, the input layer is altered to take the paired images, and the ReStyle experiments use StyleGAN2 generators. The authors make the implementation available through their project page.
Starting from an inversion of the face
The paper also uses ReStyle for toonification, the translation of a real portrait into a cartoon version. The toon generator comes from fine-tuning the FFHQ face generator, meaning that its training begins from the existing generator and adapts it to the cartoon domain. An ordinary iterative translation can begin with the average toon code and the image rendered from that code. At each pass, the encoder can then use the photograph to guide the movement toward a matching cartoon.
Encoder bootstrapping changes the initial condition. The authors first use a real-face encoder to get a code and a reconstruction of the photograph in the FFHQ generator. They supply both to the toonification procedure as its starting state. The examples of intermediate outputs show a single step of the ReStyle pSp face encoder followed by the sequence from the ReStyle pSp toon encoder. At the handoff, the initial comparison image is a reconstruction rendered by the real-face generator. Later comparison images come from the toon generator as the code is updated.
The rationale is that the starting code already describes the person to some extent. The residual encoder can use that information while adapting the result to the target appearance. This is a different use of the feedback loop from reconstructing a photograph as closely as possible in its own domain. Here, the final image should have a different style while retaining attributes of the source. Whether a face code is a useful starting point depends in part on how the real-face and toon generators interpret that code, an assumption the authors investigate separately.
Experiments and results
What was trained and what was tested
ReStyle is evaluated across domains with quite different image structure. A portrait has recognizable parts whose placement can vary, especially with pose and expression. A car has its own large-scale shape and details such as a badge or number plate. Horses, churches, and wild animals offer further tests of whether a learned correction can work when the subject and its surroundings vary. The authors train encoders for the respective domains and evaluate with generators suited to those domains.
For human faces, all 70, 000 FFHQ images are used to train the ReStyle encoders. The evaluation uses all 2, 824 images from the official CelebA-HQ test split. This is the setting for the face identity comparison and for the analysis of where changes occur during refinement. Training and testing therefore use different named face datasets, a detail that matters when interpreting the face results.
For cars, training uses the 8, 144 training images from Stanford Cars. The official test set contains 8, 041 images. The authors randomly select 1, 000 of those test images and compute the metrics on that subset. The pixel-error results for cars describe performance on that sampled evaluation set.
For LSUN Horse, the authors randomly select 10, 000 images for training and use 2, 215 images for evaluation. For LSUN Church, they use all 126, 227 training images and 300 official testing images. The AFHQ Wild experiments use 4, 738 training images and 500 evaluation images from the official dataset. Keeping these splits distinct matters because the paper presents results by domain. A good result on one split supplies evidence for that setting, with the other domains providing separate checks.
What ReStyle was compared with
The direct-encoder baselines are IDInvert, pSp, and e4e. Each predicts a code in a single forward pass. ReStyle pSp and ReStyle e4e instead apply the iterative scheme using the corresponding encoder approach as a starting point. For the optimization baseline, the authors use the inversion procedure from Karras and colleagues. Hybrid runs start from a code supplied by a conventional encoder and continue with optimization. This setup lets the reader compare learned corrections with image-specific optimization even when the latter benefits from an encoder initialization.
Some baselines use available pretrained weights, and others are trained for particular domains. The face version of IDInvert uses its official release with a StyleGAN1 generator. For cars, the authors retrain IDInvert at 512×384 input resolution with the official StyleGAN2 generator. In the paper, the authors say they retrained IDInvert only for cars because of the training cost, reporting that training took more than three weeks using two NVIDIA P40 GPUs. Different generators in the face comparison are therefore part of the actual evaluation setup.
The authors use the official pretrained pSp encoder for faces. For other domains they train pSp with StyleGAN2 and its default hyper-parameters, incorporating the MOCO-based similarity loss that the e4e work used to improve reconstruction. For e4e they train the AFHQ Wild encoder with the official implementation and default settings, using official pretrained weights for the other evaluated domains. These details explain what the baseline names stand for in each comparison. They also matter when distinguishing the broad comparison of inversion systems from the narrower architectural ablation within ReStyle.
How the quality and time measurements fit together
The paper measures reconstruction in several ways. L2 captures pixel differences, while LPIPS measures a perceptual discrepancy using image features. Lower values correspond to closer reconstructions under those criteria. For human faces, the authors also use CurricularFace, a face recognition method, to measure identity similarity between the source and the output. Higher identity similarity is preferred. This adds a measure concerned specifically with retaining the person’s identity, which can behave differently from a measure affected by changes throughout the image.
Each conventional encoder supplies a single operating point in the quality-time comparison. The authors vary the number of optimization steps from 1 to 1, 500 for the direct optimization baseline. Hybrid runs vary from 1 to 500 optimization steps after encoding. The ReStyle runs use up to 10 feedback loops. For the methods that can continue updating, measuring the output at multiple points makes it possible to compare quality at a given cost, or cost at a given quality. The paper puts both axes on logarithmic scales in its quality-time plots.
The main comparisons emphasize identity similarity for faces, L2 for cars, and LPIPS for churches. The appendix expands the plotting to L2 and LPIPS across the domains and also reports face identity similarity. The metrics answer different questions. For instance, the church comparison concerns the perceptual appearance of a scene, whereas the face identity comparison concerns whether an output still represents the source person according to the recognition method. A timing claim made at a particular face identity score should be read in that context.
Reconstruction at the reported operating points
In the face comparison, the authors report that ReStyle matches or surpasses the corresponding conventional pSp and e4e encoders. Per-image optimization reaches higher identity similarity. To match ReStyle’s identity similarity in the timing comparison, it takes ≈ 20× as long. This figure describes time at a comparable level of face identity similarity. The graph compares sequences of operating points, so the interpretation depends on which level of quality is being matched.
The car domain shows a more pronounced advantage for ReStyle over customary single-pass encoders in L2 reconstruction error. On LSUN Church, ReStyle applied to pSp comes close to the optimization and hybrid approaches on the reported LPIPS comparison while reaching that quality in substantially less time. The pattern is consistent with the paper’s argument that later encoder passes can remedy errors left by direct prediction while keeping the computation per image relatively low.
The curves also show why the full sequence matters. ReStyle can initially produce an output worse than a conventional encoder’s result. The authors relate this to its training objective across several passes. Once further corrections have been made, it quickly matches or improves upon the corresponding single-pass results in the comparisons they discuss. The opening output is valuable as a stage in the procedure, and the quality-time curves allow its cost and quality to be considered separately from those of the later output.
The architecture experiment provides exact measurements for a fixed endpoint. Both ReStyle pSp variants run for 5 steps, and the metrics describe their final reconstructions. On the CelebA-HQ test set, the original FPN configuration records LPIPS of 0.03 and mean squared error, or MSE, of 0.14. The simplified configuration records LPIPS of 0.03 and MSE of 0.13. The reported runtimes are 0.538 and 0.451, respectively. MSE summarizes the mean squared pixel difference, and the timings in the chart use the scale reported in the paper’s ablation.
ReStyle pSp encoder runtime on CelebA-HQ test faces
The simplified encoder completes the refinement sequence faster.
The numbers
| System or setting | Runtime |
|---|---|
| ReStyle pSp with FPN | 0.538 |
| ReStyle pSp with final feature map (this paper) | 0.451 |
The Stanford Cars test subset shows a difference in LPIPS between the architecture variants at the same refinement endpoint. The values are 0.08 for the pyramid and 0.07 for the simplified design. MSE is 0.26 and 0.25, respectively. These are comparisons of two implementations of the iterative procedure, so they describe the effect of the architectural choice within ReStyle. The comparison against conventional encoders comes from the quality-time experiment.
ReStyle pSp encoder LPIPS on the Stanford Cars test subset
The simplified encoder has lower perceptual error.
The numbers
| System or setting | LPIPS |
|---|---|
| ReStyle pSp with FPN | 0.08 |
| ReStyle pSp with final feature map (this paper) | 0.07 |
On the LSUN Church test set, both architectures record LPIPS of 0.09. MSE is 0.28 for the FPN variant and 0.26 for the simplified variant. The corresponding runtime values are 0.355 and 0.298. This gives an example in which the perceptual scores agree at the displayed precision while the pixel error and runtime both favor the final-map architecture.
ReStyle pSp encoder mean squared error on the LSUN Church test set
The simplified encoder achieves lower pixel error.
The numbers
| System or setting | MSE |
|---|---|
| ReStyle pSp with FPN | 0.28 |
| ReStyle pSp with final feature map (this paper) | 0.26 |
What the images add to the comparisons
The qualitative reconstruction comparison points to particulars that can matter even when the image already looks plausible at a glance. In the pSp examples, the authors draw attention to a man’s collar and a woman’s hair. For a car, the details include the Audi badge and the number plate. In examples based on e4e, ReStyle better captures aspects of the background behind wild animals and the position of a horse. These are illustrations of what a revised code can recover. The error measures describe performance over evaluation images more broadly.
The authors then apply existing latent-space editing methods to the inverted codes. For faces they use InterFaceGAN, with examples of age and smile changes. For cars they use GANSpace, with examples including viewpoint, shape, and color changes. For horses they use SeFa, with examples concerning pose and the presence of a rider. The emphasis is on ReStyle e4e because e4e was designed for image manipulation. This choice tests whether closer reconstruction can coexist with useful edits in a setting where that property already matters to the baseline.
The examples show ReStyle e4e retaining source details while allowing plausible edits. Some optimization-based car reconstructions lead to visible problems in the subsequent edit, such as artifacts around a front bumper. The illustration is pertinent precisely because the two tasks are sequential. Low reconstruction error can establish that the starting image is close under a criterion, while a change to the code tests how the generator behaves around that starting point.
In the toonification comparison, the paper shows real portraits translated using different initializations. The variant initialized from the real-face inversion better retains features such as make-up, glasses, hairstyle, and expression in the examples the authors discuss. The sequence of outputs lets the reader see the real-face reconstruction that serves as the starting state and how the cartoon changes after the handoff. This is qualitative evidence that the starting point can influence what survives the translation.
What the ablations show
Simply feeding a reconstruction back can make it worse
The paper contrasts ReStyle with a direct way to reuse an existing encoder. First invert the source with a pretrained pSp or e4e encoder, render the result, and then treat that rendering as the next input to the same encoder. This procedure has a loop and uses the same kind of forward computations repeatedly. After the first pass, however, the input being encoded is the last reconstruction. The original photograph no longer supplies a visual reference against which the output can be corrected.
The difference is significant because an encoder trained for ordinary inversion tries to represent the image it sees. If a detail has disappeared in the rendering, that version of the loop gives the encoder no image evidence of the lost detail on the next pass. Each re-encoding can add errors of its own. ReStyle maintains access to the original photograph, predicts a correction to a stored code, and trains the encoder on successive states of this procedure. The comparison gives a practical reason to treat these changes as part of the method instead of relying on repetition alone.
The authors run this comparison on faces and cars using pSp and e4e. In the displayed sequences, repeatedly encoding the latest reconstruction makes it drift away from the original. ReStyle progressively improves its outputs in those comparisons. This gives evidence for the dedicated procedure as a whole. The comparison changes the encoder input, the representation it predicts, and the training regimen together. As a consequence, the drift supports the combined design, with the contribution of each individual change unresolved by this test.
The feature pyramid contributes little at the tested endpoint
The controlled architectural comparison keeps the ReStyle procedure and the pSp basis while changing where the style inputs are extracted. In one variant the style heads draw on the FPN levels inherited from the original architecture. In the other they all draw on the last encoder map. Both variants produce their final outputs after 5 inference steps. Comparing them at that common endpoint tests whether the more elaborate feature extraction yields a reconstruction advantage large enough to show up in the reported errors.
The authors characterize the simplified version as more than 10% faster, with comparable reconstruction quality. The face, car, and church numbers illustrate the pattern. The remaining domains are consistent with it. For AFHQ Wild, LPIPS is 0.06 in both variants, with MSE of 0.23 for the FPN and 0.21 for the simpler design. The reported runtimes there are 0.413 and 0.363. On LSUN Horse, LPIPS is 0.09 for both, MSE is 0.32 and 0.31, and runtime is 0.355 and 0.298, in the same order.
These comparisons are especially relevant when the encoder’s computation is repeated. Feature extraction that gives little improvement at the final reconstruction can still incur a cost every time a new residual is estimated. The similar errors support the authors’ choice to derive all the style vectors from the last map for these runs. Each generator input still gets its own vector, so the experiment removes the dedicated feature resolutions while retaining the separate style heads.
Where the visible changes occur
The face analysis asks what changes between consecutive renderings. It is based on the actual outputs of the loop. For each source and each pair of successive reconstructions, the authors compute a squared image difference. The visual diagnostic can be expressed as follows.
d = (ŷₜ − ŷₜ₋₁)²
Here d is the image of squared differences between the two reconstructions. The symbols ŷₜ and ŷₜ₋₁ denote the generated images at the current and previous indices, respectively. The index t identifies the current reconstruction in the sequence, and t − 1 identifies the preceding one. Subtraction takes the difference at corresponding positions, and the square measures how much those image values changed regardless of the direction of the change. The equals sign defines the diagnostic for that pair of images.
The authors average the difference images across the face test samples. To see where the changes are concentrated during each transition, they normalize the average for that transition to the range [0, 1]. The upper and lower ends of this scale represent more and less change in that heatmap. An area that stands out under this normalization is an area that changed relatively strongly during that particular transition. An early map can emphasize the background or pose, and a later one can highlight the eyes or hair.
A second visualization puts the maps on a common normalization scale. With this view, the reader can compare the overall amount of change across transitions. The earliest displayed changes are the largest, and the changes become smaller as the steps progress. The two views answer complementary questions. Rescaling each map independently makes it easier to see where late corrections are concentrated. A common scale shows that the late corrections can be small even when they have a clear location.
The appendix shows individual reconstructions alongside heatmaps to complement the averages. The changes in individual examples move from broad features, such as head pose or car shape, towards more localized adjustments. The sequences also show examples of a difficult face pose being reconstructed more closely, a horse rider’s posture being refined, and a slanted church structure coming into better alignment. The sequence makes it possible to see whether a conspicuous change in a difference map corresponds to a recognizable improvement in the image itself.
The analysis supports the authors’ description of a coarse-to-fine pattern in the displayed results. Its evidence comes from differences between outputs. Those differences can locate what the encoder and generator changed together. The encoder’s internal representation, including which features it used to decide on a residual, is a separate question.
How the style inputs change
The appendix performs a complementary analysis in latent space on the cars domain. It tracks the change in each style input between adjacent inference steps. For a selected style input, the authors compute the squared component differences between successive estimates and then average across test samples.
dₗ,ₜ = (1/N) ∑ᵢ₌₁ᴺ (wₗ,ₜ⁽ⁱ⁾ − wₗ,ₜ₋₁⁽ⁱ⁾)²
The symbol dₗ,ₜ denotes the vector of average squared differences for style input l at step t. The index l runs over the generator’s style inputs, and t identifies the later step in the comparison. The index i identifies a test sample. The term wₗ,ₜ⁽ⁱ⁾ is the style vector in that slot for sample i at the later step, and wₗ,ₜ₋₁⁽ⁱ⁾ is its counterpart at the previous step. Subtraction and squaring operate component by component. The summation ∑ adds the results from sample 1 through sample N, and 1/N takes their mean. In this diagnostic N counts test samples. The method description uses the same letter for the number of steps.
The authors then summarize the vector of average squared differences with a norm.
vₗ,ₜ = ‖dₗ,ₜ‖₂
Here vₗ,ₜ is the scalar change reported for style input l and step t, and dₗ,ₜ is the vector defined by the preceding calculation. The notation ‖·‖₂ is the Euclidean, or L2, norm. It gives the size of that vector as a single value. The authors group the resulting quantities according to StyleGAN’s coarse, medium, and fine style inputs and report average change for the groups.
The coarse group moves most in the early iterations. Fine style inputs show the least change and settle after a few steps. The authors take the pattern as evidence that the residual updates decrease as the inversion progresses. This is related to, but distinct from, the spatial finding on face images. Small late changes can be visibly concentrated at places like the eyes or the hair, while the fine group in the car latent analysis can have small measured changes overall. The two analyses examine different domains and observe different quantities.
Together the diagnostics give a way to understand the usefulness of a limited number of passes. The first few rendered states can differ substantially, both in the images that are visible and in the styles that generate them. Once the largest discrepancies have been addressed in the examples, the next steps tend to make smaller changes. The measured quantities show how much the output or code moves from one step to the next. Quality comparisons with the source supply the separate evidence that those movements improve reconstruction.
Why a real-face code can help a toon encoder
The bootstrapping comparison asks whether a more informative initial state can improve translation. The average toon image supplies a generic starting point. The FFHQ inversion supplies a starting code and reconstruction already adapted to the individual input. The toonification examples suggest that this extra information carries forward, especially for details that contribute to a likeness but can easily be altered in a stylized result.
The authors also test a premise behind that transfer. For each w vector they draw at random from the FFHQ latent space, they feed that vector to both the real-face generator and the toon generator. This allows them to examine what each generator makes of an identical code independently of the inversion procedure. The example pairs show recognizable semantic similarities across the two renderings. The authors interpret that resemblance as evidence that the spaces are aligned closely enough for a real-face code to be a useful seed.
The initialization comparison and the sampled-code comparison address different parts of the explanation. The first shows the practical result of starting from an FFHQ inversion in the demonstrated translation. The second examines why a code from that generator can already carry meaning into the toon domain. The toon generator’s origin in the FFHQ generator provides context for the observed correspondence. The evidence is visual, and it applies to the particular pair examined in the paper.
Limitations
Limits stated by the authors
The authors qualify their comparison with optimization in terms of reconstruction quality and speed. Optimization usually reaches better reconstruction performance when allowed to run longer. ReStyle’s result is a more favorable balance within the tested timings, with reconstructions that can look comparable in the displayed examples. The face timing result concerns a match at ReStyle’s level of identity similarity. An application seeking the highest identity similarity reached by optimization would be using a different point on the quality-time curve.
The authors also note that ReStyle’s initial output can lag a conventional encoder. Its training allows several passes to do the work, and a comparison restricted to the first output can therefore give a different ordering from the comparison after refinement. This matters for a strict inference budget. How much of the paper’s gain is available depends on how many times the encoder and generator can be run.
For toonification, the paper explicitly identifies an assumption about the starting code. A code that represents someone in the FFHQ generator has to retain enough related meaning in the toon generator to benefit the translation. The authors offer the paired renderings of sampled codes as an explanation in this case and describe broader use of bootstrapping as a possibility. The example demonstrates transfer between the two related generators used in the experiment.
Limits visible in the experimental design
ReStyle searches for an approximation inside a fixed generator’s representation. For real inputs, the experimental target is judged by comparing reconstructions and source images. The setup does not supply a known W+ code for each photograph against which to measure recovery. A low image error or a high face identity score is evidence about the output of the generator under the corresponding measure. It cannot establish that a unique latent representation has been recovered or that all source details can be expressed through that generator.
The tested domains establish breadth within StyleGAN inversion. The experiments train domain-specific encoders and use generators for those domains. The face experiment provides evidence for training on FFHQ and evaluating on CelebA-HQ. The car results concern a random test subset of Stanford Cars. The variety of settings supports reuse of the training scheme with those data and encoder choices. A single trained encoder serving unseen domains would be a different experimental claim, as would applying the method unchanged to a different family of generators.
The comparisons of full inversion systems also incorporate the particulars of their implementations. IDInvert, for example, uses a different generator version from ReStyle in the face experiment. The fixed-step architecture ablation answers a narrower question because the two ReStyle variants share the iterative setup and differ in their feature extraction design. The timing curves answer the practical question of how the tested systems compare as run. A timing or quality difference in the broad comparison can reflect more than the presence of iterative feedback.
The naïve feedback test establishes that repeatedly encoding the last rendering can deteriorate the output. Its design combines a change in the information presented to the encoder with a change in whether a residual is predicted and how the encoder is trained. To identify the individual effect of each ingredient would require comparisons that vary them separately. Similarly, the reported architectural comparison uses a fixed refinement endpoint. The matching LPIPS values in several settings describe that endpoint and the displayed precision.
The convergence analysis measures successive movements in images or in style inputs. Diminishing differences are evidence that the process settles in the measured runs. Settling and reaching the best possible code are distinct outcomes. The averaged heatmaps and latent statistics also leave room for individual examples to change differently from the aggregate. The paper’s image sequences help show some of that variation, while the results provide no per-image guarantee of improvement at every step or a guarantee of convergence to an optimum.
The editability evidence comes from examples with selected editing tools and attributes. It shows that some improved reconstructions still respond plausibly to edits and that a close reconstruction can have a visible artifact after manipulation. The paper does not quantify the frequency of such outcomes across all evaluation images or all possible edits. In particular, the face identity measurements are taken on reconstructions. They do not measure how much identity is retained across edits of different strengths.
For toonification, the observed gains in retaining accessories, hair, or expression come from visual comparisons. The code-alignment analysis also uses visual examples of sampled inputs shared by the two generators. There is no reported numerical measure of the transfer’s reliability across portraits or of the degree of alignment between the two latent spaces. The practical result is evidence for this pairing and this translation task. Extending it to generators that were trained independently would require evidence that their codes still convey sufficiently compatible information.
What came after
The later citing work, published in 2023, addresses text-driven image-to-image translation using plug-and-play diffusion features. Its title identifies a related editing problem, in which an input image is transformed under a text instruction. ReStyle studies how to recover editable StyleGAN codes and also demonstrates a translation guided by an initial face reconstruction. The later title places the transformation in a diffusion setting and identifies text as the source of editing guidance. Plug-and-Play Diffusion Features for Text-Driven Image-to-Image Translation
The citation places ReStyle in the later paper’s account of related work. The title and citation alone leave the nature of that connection open. They do not establish that the later method uses ReStyle’s encoder, adopts additive style-code corrections, or makes a comparison against its inversion results. The documented connection is therefore between two studies of controlled transformation from an existing image, with ReStyle providing evidence about how reconstructing the source through a generator can affect the image available for editing.
Cite
Cite as Yuval Alaluf, Or Patashnik and Daniel Cohen‐Or. 2021. ReStyle: A Residual-Based StyleGAN Encoder via Iterative Refinement. IEEE/CVF International Conference on Computer Vision (ICCV).
@inproceedings{alaluf2021restyle,
title = {{ReStyle: A Residual-Based StyleGAN Encoder via Iterative Refinement}},
author = {Yuval Alaluf, Or Patashnik and Daniel Cohen‐Or},
booktitle = {IEEE/CVF International Conference on Computer Vision (ICCV)},
year = {2021},
doi = {10.1109/iccv48922.2021.00664},
eprint = {2104.02699},
archivePrefix = {arXiv},
url = {https://doi.org/10.1109/iccv48922.2021.00664}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/alaluf-2021-restyle-residual-based-stylegan-encoder/