HyperStyle: StyleGAN Inversion with HyperNetworks for Real Image Editing
Paper · 2022 · Yuval Alaluf, Omer Tov, Ron Mokady et al.
Summary
To edit a photograph with StyleGAN, an image generator, you first need a code that lets the generator recreate the photograph. A good starting image matters. If the reconstruction loses the subject’s hairstyle or changes their face, a later edit to their expression starts from those altered details. Yet a code that closely reproduces the photograph can have a problem of its own. Moving it in a direction that ordinarily produces a smile or turns the head may give a weak or distorted edit. HyperStyle addresses both requirements by keeping the initial code in a part of StyleGAN where edits tend to work and adjusting how the generator renders that code for the particular photograph.
The authors train a hypernetwork, a network that predicts adjustments to the weights of another network. It looks at the original photograph alongside an approximate reconstruction and predicts changes to selected StyleGAN filters. StyleGAN then renders the same code with the adjusted weights. The hypernetwork can inspect that improved reconstruction and refine the weights again. Its design makes this feasible by sharing an adjustment across the spatial positions of each filter channel and by reusing parts of the prediction network across several generator layers. Training teaches the hypernetwork to make these corrections across a collection of images, so a new photograph can be processed by a sequence of forward passes.
On the CelebA-HQ test set, HyperStyle records a perceptual reconstruction distance of 0.09, matching the displayed result for both StyleGAN2 latent optimization and Pivotal Tuning Inversion, or PTI. The reported inference times are 1.234 seconds for HyperStyle, 227.55 seconds for latent optimization, and 55.715 seconds for PTI. PTI leads on facial identity similarity and structural similarity. In experiments that vary head pose and smile, HyperStyle preserves identity better than the encoder baselines while supporting a comparable or wider range of changes. The results on cars and wild animals give a more qualified picture of reconstruction quality, with optimization retaining a clearer advantage.
The authors also show that a HyperStyle network trained on photographs can help reconstruct and edit selected paintings and animation-style images. In a separate experiment, adjustments predicted for a photographic face improve the preservation of details when a related generator renders that face in a new style. These examples extend the central finding. Adjusting the generator around an editable code can recover details that the initial reconstruction misses, and a learned predictor can make those adjustments much faster than a fresh optimization for each image.
Deep dive: HyperStyle: StyleGAN Inversion with HyperNetworks for Real Image Editing
HyperStyle learns to adjust StyleGAN for each input image, improving reconstruction while keeping familiar image edits fast and usable. · about 36 minutes to read
The problem and its context
Why editing begins with reconstruction
StyleGAN can generate a picture from a compact numerical description called a latent code. The code is an internal input to the generator. A person looking at it directly would see numbers, while the generator turns those numbers into an image. The authors situate StyleGAN within the family introduced in Generative Adversarial Nets.
An important property of StyleGAN is that changes in its latent representation can produce recognizable changes in its images. A direction in the space of codes can correspond to a change in expression, for example. Starting with a code that generates a face, an editing procedure moves the code along such a direction and renders the result. Similar procedures can change how a head is turned or alter the appearance of a car. The useful property is that a numerical operation on a code produces an image change a person can recognize and describe.
A real photograph reaches this pipeline from the opposite end. Its pixels are available, but the generator has no corresponding code ready to hand. GAN inversion tries to recover one. It starts with the image and works back towards an input that reproduces it when the generator runs forward. An early StyleGAN embedding approach in the authors’ account is Image2StyleGAN.
The reconstruction serves as the starting point for every later change. Consider the problem of turning a face towards the camera. The result should show a different pose while retaining the person’s identity. If the inversion already changes the person’s appearance, the editor inherits that discrepancy before it has changed the pose at all. There is a separate possibility that the inversion looks good at its starting point but responds poorly as the code moves. In that case, fidelity at the original pose gives only a partial account of whether the inversion is useful.
The choice of latent space
The paper explains this tension through two related spaces. StyleGAN has a mapping network that produces codes in a learned space called W. A code from W supplies a common starting representation for the generator’s layers. Each layer has its own transformation of that representation, so using a common code still allows the layers to act differently. The common input places a constraint on which combinations of layer-specific styles the generator can produce.
An extended space, W+, relaxes that constraint by allowing the layers to receive separate codes. During inversion, the extra freedom gives the reconstruction procedure more ways to fit a real image. One layer’s input can change without requiring the same change at another layer. This can help recover details that a single shared code cannot express well.
An editing direction, however, needs to work along a path through the space. An inversion in W+ can be an effective fit at its particular starting point while sitting in a region where the generator’s response to that direction is less coherent. In the earlier work discussed by the authors, inversions in W generally support stronger semantic control, while the greater expressive range of W+ can reduce reconstruction distortion. The paper also describes a compromise pursued by earlier methods. They seek layer-specific codes that stay close to W, preserving some of the flexibility of W+ while favoring parts of the space where editing behaves well. The e4e encoder, which HyperStyle uses to initialize its inversions, comes from this line of work.
The paper calls this the distortion–editability tradeoff. Here distortion is the discrepancy between an image and its reconstruction. Editability concerns the changes an inversion can support and what happens to the rest of the image as those changes are applied. A search guided by distortion evaluates how well the current output matches the photograph. The editability question concerns other outputs that the same code will lead to once a direction is applied. Keeping those questions distinct helps explain why gaining expressive freedom can improve one measure and weaken the other.
Searching for a code and learning to predict one
The earlier inversion methods described in the paper differ in how they obtain the latent code. Direct optimization starts with a candidate code, generates an image, compares it with the photograph, and adjusts the code to reduce the discrepancy. The process repeats for the individual image. It can make a close reconstruction, but the authors describe classical latent optimization as taking several minutes per image. Computational work goes into solving a new instance each time.
An encoder learns a mapping from photographs to codes over a collection of training images. Once trained, it can predict a code for a new photograph in a forward pass, meaning one evaluation through the network. The paper describes this family of approaches as taking a fraction of a second, with reconstructions usually less faithful than those found through optimization. Hybrid inversion methods combine learned prediction and search. They offer another way to divide the work between training on a collection and processing a particular image.
Iterative encoding lets the learned mapping make corrections over repeated passes. ReStyle, an earlier method that informs HyperStyle, uses a current reconstruction to help refine the latent code. That gives the next prediction access to the consequences of earlier predictions. HyperStyle adopts the feedback arrangement and directs the corrections to the generator’s weights. ReStyle
Editing itself had developed along several lines. The paper describes methods that use labeled traits or prior knowledge about faces, methods that find directions without such supervision, and approaches that combine latent codes for more localized changes. It also describes editing guided by connections between images and language. StyleCLIP is an example of text-driven editing in StyleGAN and is among the existing editors the authors use to demonstrate their inversions. StyleCLIP
These methods place a practical demand on inversion. An image representation that requires a new editor for every input would forgo the existing ways of manipulating the generator. HyperStyle is designed around retaining access to those controls. The inversion should produce a starting point that the original editing directions can act on, along with a generator that draws the subject’s details more faithfully.
Adjusting the generator around an editable code
The authors describe generator tuning as another way to improve reproduction. The inversion first obtains a code that approximates the source and lies where latent edits tend to behave well. The procedure then changes the generator’s weights so that this same code yields a closer match. Holding the code in place moves the burden of recovering missing detail to the generator. The resulting representation consists of a code together with the particular generator weights that render it.
The paper discusses earlier generator tuning in the context of BigGAN as well as StyleGAN. In the BigGAN approach it describes, a procedure samples candidate noise vectors, chooses the one that gives the closest starting image, and optimizes the input together with generator weights. This is a different way to use the flexibility of a pretrained generator, since both sides of the rendering process can change. Large Scale GAN Training for High Fidelity Natural Image Synthesis
Pivotal Tuning Inversion, which the paper abbreviates as PTI, first finds an approximate latent representation and then tunes the generator around that fixed pivot. Its cost comes from carrying out the tuning for each new image. HyperStyle takes the same broad idea of rendering a fixed code with image-specific weights and learns how to predict those weight changes. The analogy with a conventional encoder is direct. An encoder learns to predict the outcome of a search for a code. HyperStyle learns to produce the kind of weight adjustment that would otherwise be obtained through image-specific optimization.
A network that predicts weights for another network is called a hypernetwork. The paper places this design in a broader history of input-dependent weight prediction, including applications in segmentation, shape processing, and continual learning. HyperSeg is one example the authors cite of using a hypernetwork for semantic segmentation. HyperStyle uses the mechanism for a different task, where the primary network is a pretrained generator and the prediction takes the form of a correction to its existing weights. HyperSeg
The method, step by step
From a photograph to an editable reconstruction
HyperStyle begins with an ordinary inversion. A pretrained e4e encoder estimates a code for the input photograph, and the original StyleGAN generator renders it. The authors use e4e to place the initial estimate in an editable region and keep the encoder fixed while training HyperStyle. Accordingly, any improvement made during the subsequent passes has to come through the weight adjustments.
The approximate reconstruction gives the hypernetwork a view of what the generator can already reproduce with the chosen code. The target photograph shows what the result should look like. The images are supplied together as input, so the hypernetwork can learn which differences to respond to. It might encounter a reconstruction that already has the right head position but misses some of the shape or texture of the hair. The system learns through reconstruction error whether a predicted adjustment helps. It receives no annotation designating the hair or assigning that discrepancy to a particular layer.
A shared feature extractor processes the image pair. Separate output blocks use its features to predict changes to selected StyleGAN layers. Each block predicts the adjustments for a particular layer. The adjusted generator renders the same latent code again, and the new image then serves as the approximate reconstruction for the next pass. Later predictions build on the adjustments already made. At the end, the generator and the code can be used together for editing.
HyperStyle inversion and editing
The steps in order.
This arrangement separates the decisions that produce the inversion from those that produce an edit. The inversion aims to recover the source image. Afterward an editing method can steer the latent code, with the image-specific weights still in use. For a pose change, the hypernetwork does not have to receive the desired pose or predict another set of weights for it. The edit comes from a direction in the latent space.
The objectives behind the procedure
The paper starts from the usual optimization formulation of GAN inversion. It treats the target as given, holds the pretrained generator fixed, and searches for a code that minimizes reconstruction loss.
ŵ = arg min over w of L(x, G(w; θ))
Here x is the target image, w is a candidate latent code, and ŵ is the selected code. G is the generator, and θ denotes its weights. The expression G(w; θ) is the image it generates using code w and weights θ. L measures the discrepancy between that image and x. The phrase arg min asks for the code at which the loss is smallest. The semicolon inside the generator notation separates the input code from the weights used to render it.
A conventional encoder learns to produce a code by minimizing reconstruction error across training examples. Its supervision can come from the target images themselves. The loss measures what happens when an encoded image is passed through the generator, so the training objective can be evaluated even without a recorded latent code for each photograph.
∑ᵢ₌₁ᴺ L(xᵢ, G(E(xᵢ); θ))
The sum runs over the training images. N is their count, i is the example index, and xᵢ is the image at that index. E is the encoder, and E(xᵢ) is the code it predicts for xᵢ. The generator G uses fixed weights θ to render that code, and L measures the reconstruction discrepancy for the example. Training adjusts E to reduce the summed loss.
Pivot-based generator tuning changes the variable searched over. It starts from a chosen latent code and asks which generator weights give the best reconstruction with that code.
θ̂ = arg min over θ of L(x, G(ŵ_init; θ))
In this expression, ŵ_init is the initial inversion code and stays fixed. The candidate generator weights are θ, and θ̂ denotes the selected weights. The generator G renders the fixed code with each candidate weight set. L measures the discrepancy between the rendering and the target x, and arg min selects the weights that give the smallest loss.
HyperStyle uses the same basic objective but trains a predictor of the weight adjustments. Before this predictor acts, the original generator produces a reference rendering.
ŷ_init = G(ŵ_init; θ)
Here ŷ_init is the initial approximate reconstruction, ŵ_init is the code estimated by the initial encoder, G is the generator, and θ gives its original weights. The hat marks the image as an estimate, and the subscript init identifies the starting point of the refinement.
For its overview, the paper writes the hypernetwork as a function that returns the adjusted weights. In the implementation, that notation includes the operation of applying the predicted offsets to the original weights.
θ̂ = H(ŷ_init, x)
In this shorthand, H is the hypernetwork together with the application of its predicted offsets. Its arguments are the approximate rendering ŷ_init and the target x. The output θ̂ represents the adjusted generator weights. Keeping both images in the argument list makes clear that the prediction is conditioned on the current fit as well as the desired image.
The authors then express HyperStyle training as reconstruction loss across images. Its resemblance to the encoder objective is intentional. Both objectives train a network by evaluating generated images. They differ in whether the learned prediction supplies a code or changes how the generator renders an existing code.
∑ᵢ₌₁ᴺ L(xᵢ, G(ŵ_init⁽ⁱ⁾; H(ŷ_init⁽ⁱ⁾, xᵢ)))
The summation index i runs through the N training images, and xᵢ is the target for example i. The superscript ⁽ⁱ⁾ labels quantities belonging to that example. Its initial code is ŵ_init⁽ⁱ⁾ and its approximate reconstruction is ŷ_init⁽ⁱ⁾. H supplies adjusted weights from the approximate image and target. G uses those weights to render the initial code, and L compares the output with xᵢ. The equation describes the objective in the overview. In the iterative implementation the loss is evaluated at each refinement step.
Once an inversion is available, latent editing acts on the code while the generator retains the weights associated with the image.
y_edit = G(f(ŵ_init); θ̂)
Here f is the chosen latent manipulation, ŵ_init is the fixed starting code from inversion, and f(ŵ_init) is its edited version. The adjusted generator weights are θ̂. The output y_edit is the image obtained when G renders the edited code with those weights. A direction that changes the extent of a smile is one example of an operation f can represent.
What the hypernetwork predicts
StyleGAN2 has several groups of parameters with different jobs. The mapping network produces a code in W. Affine transformations associated with the generator layers turn the code into factors that modulate convolutions. Feature-space convolutions build the internal representations used to synthesize the image. Separate toRGB convolutions map those representations into contributions in RGB image space. HyperStyle applies its corrections to selected feature-space convolutions.
A convolutional filter contains weights on a small grid for each input channel it reads. At each position where that filter is applied, the weights determine how input values at nearby locations contribute to its output. Predicting a different adjustment for every grid position in every channel of every filter would let the hypernetwork reshape each kernel in detail. The cost would come largely from the layers that have to produce such a large output. The paper gives an approximate parameter count of 30M for StyleGAN and reports 3.07B trainable parameters for its naïve hypernetwork design.
The authors constrain the prediction by having the hypernetwork emit a scalar for each input-channel and output-filter pair. The scalar applies across the spatial grid for that pair. That lets the predictor increase or decrease a channel’s contribution while preserving the spatial pattern of the original weights within it. Different channels of one filter can receive different adjustments, and the same input channel can be adjusted differently across output filters.
θ̂ℓ,ᵢ,ⱼ = θℓ,ᵢ,ⱼ · (1 + Δℓ,ᵢ,ⱼ)
Here ℓ indexes a selected generator layer, i indexes an output filter in that layer, and j indexes a channel entering the filter. The array θℓ,ᵢ,ⱼ contains that filter channel’s original spatial weights, and θ̂ℓ,ᵢ,ⱼ contains the adjusted version. The hypernetwork predicts the scalar Δℓ,ᵢ,ⱼ for the pair. The dot denotes multiplication of all entries in the array by the scalar factor in parentheses. The constant 1 makes the original weights the reference point, so a zero offset leaves the filter channel at its original scale.
The size of the layer’s full weight array is k × k × C_in × C_out. In this notation k is the spatial kernel width and height, C_in counts the input channels, and C_out counts the output filters. The predicted array has size 1 × 1 × C_in × C_out. Its spatial dimensions indicate that it contains a single adjustment for each channel and filter pair. During application that adjustment is broadcast over the kernel, meaning the same value is used at every spatial position in the corresponding pair. The generator still uses its full spatial kernel when it renders an image.
This prediction rule is more specific than adding an arbitrary residual to the generator weights. The original weights supply the form of every kernel, and the predicted factors determine how strongly the channels contribute. Adding flexibility to the prediction head would allow some spatial positions to change relative to others. The authors later test a structured way to do that.
How the predictor is built
The target and reconstruction are joined along their color channels to form a 6-channel input. A ResNet34 backbone processes this input. It starts from weights pretrained on ImageNet, and its input layer is adapted to accept the image pair. The output is a 16 × 16 × 512 feature map, with spatial dimensions followed by the channel dimension. This map provides a common representation of the pair for all the output blocks. Deep Residual Learning for Image Recognition
Each refinement block receives that map and reduces its spatial dimensions using convolutions. The standard block’s layout uses 3 × 3 convolutions and LeakyReLU activations, which provide the nonlinear transformations between them. Adaptive pooling brings the representation down to 1 × 1 × 512. A fully connected layer then turns this compact representation into the 1 × 1 × C_in × C_out offset array. The final dimensions correspond to the particular StyleGAN layer that the block serves.
A separate design is used for selected layers with 3 × 3 × 512 × 512 convolutional weights. These layers have the same input and output dimensions, which makes it possible to share the parameters that produce their large output arrays. The Shared Refinement Blocks retain independent downsampling computations for the individual heads. The heads then use a common pair of fully connected transformations. As a result, their outputs can vary by layer because the features presented to the common transformations can differ.
In the shared design, the late part of the head expands a 1 × 1 × 512 representation into an intermediate array of size 512 × 512. A subsequent transformation acts per channel and gives the final 1 × 1 × 512 × 512 offsets. The sharing is inside the hypernetwork. Filters in different StyleGAN layers retain their own weights, and the predicted offsets for those layers are calculated from the feature representation of each head. Sharing the output transformations reduces the need to learn an independent large mapping for every eligible layer.
The parameter comparison in the paper gives 367M trainable parameters for the per-channel design before adding shared refinement and 332M for the combined design. It reports the combined reduction as 89% relative to the naïve network. For scale, the same comparison lists 267M for pSp and e4e and 205M for ReStyle. These counts refer to the trainable prediction networks compared by the authors. They convey why structuring the output matters even though the task begins with a pretrained generator. The resulting hypernetwork is closer in size to the encoders than to a network with an independent output for every convolution weight.
Deciding which generator weights can change
The final design predicts offsets for the medium and fine feature-space convolutions. The paper adopts StyleGAN’s grouping into coarse, medium, and fine levels of detail. The authors observe that the initial inversion tends to recover coarse properties already. They use the prediction capacity where they expect more of the remaining errors to occur, in the medium and fine groups. Giving a layer no refinement head also removes the need to generate offsets for it on every pass.
The study makes a separate decision about the affine and toRGB layers. For a fixed image and its inversion code, the authors argue that a change to the affine modulations can be represented by a corresponding rescaling of convolution weights. The final system places its image-specific correction in the convolution weights themselves. At editing time, the generator still uses its existing affine transformations to interpret the changed code.
The toRGB layers remain fixed because of what happened when the authors allowed the hypernetwork to change them. Their qualitative comparisons show artifacts during global edits, including changes in pose and age. The authors suggest that tuning the RGB projections may chiefly adjust pixel-level texture and color in ways that fail to carry over when a larger feature of the image changes. This mechanism is their explanation for the observation. The direct evidence is the visual difference between settings that include the toRGB layers and those that leave them alone.
The layer selection defines the part of the generator that HyperStyle can customize for the photograph. Its effect depends on both the initial code and the weight structure inherited from StyleGAN. The hypernetwork is asked to recover detail using those existing components, with the coarse representation and direct color projections providing a stable basis for later manipulation.
Refining the same code over repeated passes
The first pass sees an image made with the pretrained generator. The next pass sees the effect of the first correction. Each pass supplies another offset, which is accumulated with what has already been predicted. This gives the network a chance to correct residual differences exposed by the previous rendering. The initial code stays in place through the entire sequence.
Δₜ = H(ŷₜ₋₁, x)
Here t is the current refinement step, and Δₜ is the collection of new offsets predicted at that step. H now denotes the offset predictor itself. Its inputs are ŷₜ₋₁, the rendering from the previous step, and x, the original target. At the first refinement step the previous rendering is the initial image from the original generator.
θ̂ℓ,ₜ = θℓ · (1 + ∑ᵢ₌₁ᵗ Δℓ,ᵢ)
The index ℓ denotes a generator layer and t denotes the current step. The index i in this sum counts refinement steps. The quantity Δℓ,ᵢ is the offset array predicted for layer ℓ at step i. The sum accumulates those arrays from the first step through t. The original layer weights are θℓ, and θ̂ℓ,ₜ gives the layer weights at step t. The factor beginning with 1 is applied channel-wise, using the spatial broadcasting described above.
ŷₜ = G(ŵ_init; θ̂ₜ)
Here ŷₜ is the rendering at step t. G takes the same initial latent code ŵ_init on each pass, and θ̂ₜ denotes the full set of generator weights in use at that step. It includes both the layers adjusted through accumulated offsets and the layers that retain their pretrained values. At the final step this rendering is the reconstruction produced by the inversion.
Seeing the updated image is central to the repeated use of H. The second prediction is conditioned on a different reconstruction from the first, although the target photograph is unchanged and the weights of the hypernetwork itself are shared across passes. For example, the latest rendering may reveal that an adjustment recovered some hair detail but left another feature too smooth. The next pass can use the changed evidence. The network learns from these image pairs during training. At inference, it repeats the learned operation using forward passes through the predictor and generator.
What the training loss rewards
The authors train on the discrepancy between the input image and each intermediate reconstruction. They combine a pixel loss, a perceptual loss, and a similarity loss whose features depend on the domain.
L₂(x, ŷ) + λ_LPIPS L_LPIPS(x, ŷ) + λ_sim L_sim(x, ŷ)
In this expression x is the target image and ŷ is the reconstruction being evaluated. L₂ is the pixel-wise loss. L_LPIPS is the perceptual loss, which compares the images through learned visual features. L_sim is the domain-specific similarity loss. The positive weights λ_LPIPS and λ_sim set the contributions of those two terms relative to the pixel term. The plus signs indicate that the terms contribute to one reconstruction objective.
For faces, the similarity term uses features from a pretrained ArcFace recognition network, with λ_sim set to 0.1. For the remaining domains, the paper uses a MoCo-based similarity loss and sets λ_sim to 0.5. The LPIPS loss weight is 0.8. Together the terms give different signals about the fit. A small color or position discrepancy can register directly in the pixels, perceptual features provide another measure of visual similarity, and the facial similarity term specifically encourages preservation of identity.
Training uses T = 5 refinement steps per batch, where T denotes the total number of passes. The loss is computed on the rendering at each step, giving the network a learning signal for intermediate outputs as well as the last one. The authors report a batch size of 8, a constant learning rate of 0.0001, and the Ranger optimizer. They ran the experiments on a single NVIDIA Tesla P40 GPU. For the facial domain, the training images come from FFHQ. The paper makes the HyperStyle code available through its project page.
Experiments and results
How the comparisons are set up
The main reconstruction experiment trains on FFHQ and evaluates on the CelebA-HQ test set. The authors also evaluate cars on Stanford Cars and present supplementary results for AFHQ Wild. The face experiment has the fullest comparison because it includes both a recognition-based identity measure and an editability analysis. The other domains test reconstruction and demonstrate editing through examples.
The baseline methods span different ways of spending computation. The StyleGAN2 optimization baseline searches for a latent code in W+. PTI optimizes generator weights around an initial pivot. The paper also compares pSp and e4e, which directly predict latent representations, and the versions of ReStyle that iteratively refine pSp or e4e inversions. IDInvert appears in the facial reconstruction comparison, with additional visual examples in the appendix.
The evaluation allows repeated steps for both HyperStyle and ReStyle. The authors continue until the metric scores cease improving or the evaluation reaches 10 iterations. This differs from the 5 refinement steps used to train iterative HyperStyle. The latent optimization baseline can run for up to 1, 500 steps, and PTI can use up to 350 pivotal tuning steps. The time results therefore refer to the methods as run in the reconstruction comparison, with their respective refinement procedures.
The metrics cover different aspects of the reconstruction. L₂ measures differences in pixel values. LPIPS measures distance in learned perceptual features. Lower values indicate a closer match on either distance. MS-SSIM measures structural similarity across scales, with higher scores preferred. The facial experiment also measures identity similarity between the source and reconstruction using a pretrained recognition network. Higher identity similarity indicates that the network represents the two faces more similarly. Time is reported in seconds.
The face-recognition network used to evaluate identity is CurricularFace. The training objective for the facial domain uses ArcFace. This distinction matters because the identity column describes the score assigned to reconstructions by the evaluation network. The ArcFace term belongs to the procedure that teaches HyperStyle to produce those reconstructions.
Reconstruction on the CelebA-HQ test set
At the precision reported for perceptual distance, HyperStyle reaches the same result as both optimization methods. The gap between it and the encoder baselines includes the iterative variants, with ReStyle pSp closest among those shown in the chart. The chart isolates perceptual distance because the methods’ relative standing varies across reconstruction measures.
Perceptual reconstruction distance on the CelebA-HQ test set
HyperStyle matches the optimization methods and has lower perceptual distance than the encoder baselines.
The numbers
| System or setting | LPIPS |
|---|---|
| e4e | 0.20 |
| pSp | 0.17 |
| ReStyle e4e | 0.19 |
| ReStyle pSp | 0.13 |
| StyleGAN2 latent optimization | 0.09 |
| PTI | 0.09 |
| HyperStyle (this paper) | 0.09 |
For identity similarity on the same test set, HyperStyle scores 0.76. The StyleGAN2 optimization result is 0.78 and PTI scores 0.85. ReStyle pSp is the strongest encoder baseline by this measure at 0.66, while pSp gives 0.56 and e4e gives 0.50. Thus the perceptual distance result sits alongside a measured identity advantage for PTI. The identity score also shows how much the hypernetwork changes the outcome relative to the methods that modify latent codes through learned prediction alone.
On structural similarity, HyperStyle records an MS-SSIM score of 0.84 on the CelebA-HQ test set. StyleGAN2 latent optimization reaches 0.90 and PTI reaches 0.92. ReStyle pSp gives 0.79. On pixel distance, HyperStyle records L₂ of 0.019, alongside 0.020 for StyleGAN2 latent optimization and 0.015 for PTI. ReStyle pSp gives 0.030. Reading these measures together explains the paper’s claim of comparable reconstruction to optimization on faces. The exact pattern ranges from a perceptual tie at the displayed precision to a structural advantage for the optimization methods.
The runtime comparison places HyperStyle above the encoders in cost and well below either optimization-based procedure. The ReStyle entries include their repeated encoder passes. HyperStyle’s time covers the inversion used for this reconstruction comparison.
Inference time for reconstruction on the CelebA-HQ test set
HyperStyle takes longer than the encoder baselines and finishes much sooner than either optimization method.
The numbers
| System or setting | seconds |
|---|---|
| IDInvert | 0.04 |
| pSp | 0.106 |
| e4e | 0.106 |
| ReStyle pSp | 0.366 |
| ReStyle e4e | 0.366 |
| HyperStyle (this paper) | 1.234 |
| PTI | 55.715 |
| StyleGAN2 latent optimization | 227.55 |
The visual comparisons show what these measurements can mean for individual photographs. The authors present examples where HyperStyle preserves the shape of a complex hairstyle or the appearance of clothing more closely than ReStyle. They also show a low-resolution source for which PTI produces a visibly blurred reconstruction. They interpret that example in light of PTI’s per-image fitting, whereas HyperStyle learned its corrections across a training collection. This is an observation about the example shown. The aggregate scores measure reconstruction across the test set and do not isolate the effects of source resolution.
There is a difference between the time needed to find a starting representation and what it costs to use it for an edit. The reported reconstruction time measures inversion. Once the code and adjusted weights have been obtained, the editing examples use an existing latent manipulation and render with those weights. The paper’s efficiency result is principally about avoiding a fresh search for the inversion when a new source photograph is introduced.
Reconstruction on cars and wild animals
The Stanford Cars comparison changes the balance among the methods. HyperStyle reaches 0.67 MS-SSIM, 0.27 LPIPS, and 0.07 L₂, with a reported inference time of 0.491 seconds. ReStyle pSp gives 0.66 MS-SSIM, 0.25 LPIPS, and 0.07 L₂, taking 0.359 seconds. HyperStyle has a slightly higher structural score and the same displayed pixel distance. ReStyle pSp has the lower perceptual distance in this domain. The benefit over pSp and e4e is clearer than the comparison with the stronger iterative baseline.
Both optimization methods have better reconstruction scores than HyperStyle on Stanford Cars. StyleGAN2 latent optimization measures 0.79 MS-SSIM, 0.16 LPIPS, and 0.06 L₂, taking 198.9 seconds. PTI records 0.93 MS-SSIM, 0.11 LPIPS, and 0.01 L₂, with a time of 33.71 seconds. The time advantage of the learned approach persists, while the quality difference is larger than in the facial experiment. This makes the car results a useful test of how far the main face finding carries across domains.
On AFHQ Wild, HyperStyle reports 0.56 MS-SSIM, 0.24 LPIPS, and 0.06 L₂ in 0.551 seconds. ReStyle pSp gives 0.57 MS-SSIM, 0.21 LPIPS, and 0.05 L₂ in 0.303 seconds. ReStyle pSp has the stronger reconstruction result on all three of those measures. HyperStyle is ahead of the single-pass encoder baselines on the reported quality measures, so the comparison again depends on which class of encoder provides the reference point.
The wild-animal optimization results show a larger quality gap. StyleGAN2 latent optimization has 0.82 MS-SSIM, 0.13 LPIPS, and 0.03 L₂, taking 203.0 seconds. PTI has 0.93 MS-SSIM, 0.08 LPIPS, and 0.01 L₂, taking 33.71 seconds. The authors also illustrate StyleCLIP editing on the AFHQ Wild test set. Those examples address the kinds of edits the inversion supports, while the reconstruction scores describe how closely the unedited inversion resembles its source.
Measuring identity through an edit
To evaluate editability, the authors ask how far a method can change an attribute and how much identity it preserves at a given degree of change. Equal movements in latent space can produce unequal changes in two reconstructed faces. A method whose image shows only a slight smile could appear to preserve identity better than another method whose output shows a much stronger smile. A comparison at the same numerical step along each direction would mix the effectiveness of the edit with identity preservation.
The paper varies the step along an editing direction and measures the visible change with an attribute-specific predictor. HopeNet estimates head pose, and the authors use the smile classifier from the work of Lin and colleagues to estimate smile extent. CurricularFace scores identity similarity between the edited result and the original photograph. The plots place the measured change on the horizontal axis and identity similarity on the vertical axis. The resulting curve shows both the range of achieved edits and the similarity to the source at different points along that range.
At comparable measured changes, the HyperStyle curves show better identity preservation than those of the encoder baselines and reach an equal or greater span of edits in the reported experiments. The authors describe its identity and range as similar to the strong optimization-based comparisons while retaining the inversion-time advantage. The underlying distinction between latent optimization and pivotal tuning is important here. Optimizing into W+ can fit the source closely, and PTI has the additional advantage of tuning the generator around an editable code. The visual comparisons show that the editing behavior of the two optimization methods can differ even when each gives a good unedited reconstruction.
In the qualitative face comparisons, some W+ inversions produce artifacts or an incomplete turn toward a frontal pose. The paper identifies examples in which e4e and ReStyle e4e permit the intended movement but give up some of the original identity in the process. The HyperStyle and PTI examples more frequently retain the identity while making a substantial pose change. For cars, the authors report difficulty achieving conspicuous color and shape changes with several inversions into W+. The appendix illustrates HyperStyle edits with GANSpace on cars, and with InterFaceGAN and StyleCLIP on faces. These examples show compatibility with existing editing procedures on different kinds of input. The pose and smile curves provide the more systematic evidence about how editing strength relates to preserved facial identity.
Transferring corrections and editing unfamiliar styles
In one additional experiment, the starting photograph belongs to the source domain of a pretrained face generator. The desired output belongs to a related domain represented by a generator already adapted to that style. The authors obtain the photograph’s latent code and predict HyperStyle offsets using the source generator. They then apply the same offsets to the adapted generator and pass in the original code. The procedure relies on the correspondence between the two generators’ latent representations.
The comparison examines the adapted generator with and without offsets. In the examples, transferring the code by itself can lose hair color or facial hair. Using source-predicted offsets helps retain these details while preserving the appearance of the target style. The paper illustrates this with Toonify and with generators adapted using StyleGAN-NADA. The hypernetwork was trained in the source domain. It can contribute the image-specific corrections without a separate training run for each target style.
The out-of-domain inversion experiment changes the role of the unfamiliar style. Here the input itself can be a painting or an animation-style image. The FFHQ-trained HyperStyle system and its face generator attempt to reconstruct that image and provide an editable inversion. The authors compare with the e4e starting point and show reconstructions and edits in which weight adjustments help recover properties of the unfamiliar input. Some of the examples were produced by StyleGAN generators adapted with StyleGAN-NADA. The application therefore includes challenging departures from photographic appearance with varying degrees of connection to the source generator’s domain.
The two experiments probe different uses of the predicted offsets. Transfer asks whether a correction computed in one generator remains helpful when a related generator renders the image. Out-of-domain inversion asks whether the original generator can be adjusted to represent an input outside its photographic training domain. They offer visual evidence that an offset can convey useful information about an individual image beyond the immediate training setup.
What the ablations show
Refinement across successive renderings
The ablation study varies the number of passes, the generator layers eligible for adjustment, and the construction of the prediction heads. Its most direct test of iteration compares the medium-and-fine configuration used for HyperStyle after either 1 or 10 passes. The reported facial identity similarity rises from 0.66 to 0.76. LPIPS moves from 0.11 to 0.09, and L₂ moves from 0.021 to 0.019. The recorded inference times for these ablation runs are 0.15 and 1.23 seconds respectively. The added computation buys improvement on each reported reconstruction measure in that comparison.
The visual results explain where the improvement can be seen. The authors show hair and facial hair rendered more sharply, with fewer visible artifacts after successive revisions. Because the latent code stays fixed throughout the sequence, these changes demonstrate what the iterative weight adjustment can recover from the same starting representation. The ablation compares the iterative training and inference scheme with the setting without it. It leaves open how much of the improvement comes from supervision of intermediate reconstructions and how much comes from giving an already trained predictor additional evaluations.
The 10-pass comparisons in the ablation table also provide a common setting for comparing the refinement head designs. They remove variation in the number of passes from those rows. This matters because an architecture that makes better use of each pass and one that simply uses more passes could both look stronger if the comparison changed both at once.
Adjusting more generator layers
The paper compares single-pass settings that adjust medium and fine layers only, add the coarse layers, or also include toRGB layers. The single-pass identity results are 0.66 for medium and fine, 0.67 with coarse layers added, and 0.68 with toRGB layers also included. The same settings have LPIPS values of 0.11, 0.10, and 0.10. This comparison shows that making more layers adjustable can improve the measured fit of a single reconstruction. The final design has to be judged on how the weights behave during an edit and on what happens with iterative refinement.
At 10 passes, the standard medium-and-fine configuration reaches 0.76 ID, 0.09 LPIPS, and 0.019 L₂. The configuration that includes coarse feature-space convolutions records 0.74 ID, 0.10 LPIPS, and 0.02 L₂. The times are 1.23 seconds for the standard setting and 1.54 seconds with coarse refinement. In these runs, expanding the set of adjustable layers makes inference slower and gives weaker reported reconstruction scores. The result fits the authors’ observation that the initial inversion typically captures coarse structure.
The evidence for excluding toRGB includes a separate visual comparison. Changing the output projections can look helpful when an image is judged solely at the original code. The authors’ examples show how the choice plays out after a global edit. In a pose example, the version with toRGB refinement produces a blur when the head is turned. In age edits, the standard configuration gives more convincing changes involving clothing and hair. The comparisons show that a layer selection that helps the initial fit can affect the way the generator responds away from the original code. The authors’ explanation about adapting pixel-level texture and color is consistent with the examples, while the study evaluates the artifact itself through the resulting images.
Sharing output weights across heads
The authors compare the shared head with a version that omits shared refinement. Both use medium and fine feature-space convolutions and run for 10 passes. Identity similarity falls from 0.76 in the standard design to 0.68 without the shared refinement. LPIPS goes from 0.09 to 0.12, and L₂ from 0.019 to 0.022. The time is 1.23 seconds with sharing and 1.36 seconds in the alternative. Sharing therefore accompanies stronger reconstruction scores in the reported comparison as well as the smaller predictor described in the architecture section.
An independent head has to learn the full output transformation for its layer. The shared design lets multiple heads draw on the same transformation while supplying different features to it. The authors interpret the performance difference as evidence that the common parameters help the heads use information across layers. The controlled comparison supports the design choice as a whole. It does not trace which information is shared or identify an individual head responsible for the improvement.
Allowing offsets to vary within the kernel
The separable convolution variant tests how restrictive the final prediction rule is. Its motivation comes from separating channel dimensions so that a joint adjustment can be built from narrower predictions. For a kernel with spatial size k × k, the head predicts arrays of sizes k × k × C_in × 1 and k × k × 1 × C_out. Here k describes the spatial extent, C_in is the number of input channels, and C_out is the number of output filters. The two arrays are multiplied with their singleton dimensions expanded, yielding a spatially varying offset for each input and output channel pair. MobileNets
The resulting head can assign different corrections to different locations within a filter channel, while the factorization still constrains the possible combinations. The ablation therefore tests one practical form of spatially varying prediction. On the reported facial reconstruction comparison, the separable head gives 0.71 identity similarity and 0.10 LPIPS, with L₂ of 0.019 and a time of 1.28 seconds. The standard head reaches the same displayed pixel distance and stronger perceptual and identity scores. The gain in flexibility did not produce a gain on the reported measures for this variant.
Facial identity similarity in the CelebA-HQ reconstruction ablations
The standard iterative design has the highest identity similarity among the tested refinement settings.
The numbers
| System or setting | ID similarity |
|---|---|
| Medium and fine, single pass | 0.66 |
| Iterative with coarse refinement | 0.74 |
| Iterative without shared refinement | 0.68 |
| Iterative with separable convolutions | 0.71 |
| HyperStyle (this paper) | 0.76 |
Together the head comparisons clarify what is sufficient for the reported face experiment. Useful adjustments can come from scaling channels while keeping each channel’s original spatial weight pattern. Repeatedly applying that simple prediction with access to the updated reconstruction produces stronger results than the tested increase in spatial flexibility. Sharing a portion of the large output heads also improves the reported fit, even though it limits the number of separately trainable parameters.
Limitations
Limits identified by the authors
The authors identify generalization beyond the training domain as unfinished. They single out robustness to unaligned images and to unstructured domains. The demonstrations with paintings and animation-style faces retain recognizable structure that the face generator can use. They give a reason to investigate more varied inputs, while the authors treat broader robustness as a future goal. They suggest StyleGAN3 as a possible avenue for unaligned images and richer training data as a possible avenue for less structured domains.
The paper also discusses performance on groups that are underrepresented in the training data. The authors say that training-set bias can lead to degraded results for minority classes. Their examples of unfamiliar inputs motivate the possibility that weight adaptation can preserve some details prior approaches miss. A claim about fairness would require measuring performance for those groups directly, across enough relevant images and edits to assess whether a difference persists. The paper’s broader-impact discussion expresses that possibility as a hope for downstream use. Bias, fairness & safety
The authors also identify a possibility of misuse in convincing face manipulation and disinformation. They point to existing research on detection of synthesized imagery as grounds for expecting some mitigation. The HyperStyle experiments address inversion quality, editing, and transfer. The discussion of detection concerns work outside those experiments, so the paper establishes neither how reliably such edits would be detected nor how detection performance changes with the degree of manipulation.
Limits of the measurements
The strongest reconstruction comparison is the one on faces. On the CelebA-HQ test set, the equality in displayed LPIPS supports the claim that HyperStyle can reach the perceptual reconstruction quality of the optimization methods in this setting. PTI leads on identity, structure, and pixel distance, and the car and wild-animal results show a wider gap. The reported balance of fidelity and speed therefore depends on the domain and on which measure matters for the intended use.
The timing comparison is specific to the reported implementation and experiment setup. It reflects different caps for iterative inference, latent optimization, and pivotal tuning. It also uses one reported GPU type. The results show a large difference under the paper’s conditions. They leave open the latency attainable under different hardware and stopping rules, and the quality each method could reach if given a common time budget.
The pose and smile curves improve on comparisons at an equal latent step. Their interpretation still depends on the attribute estimators and the face-recognition score. A pose estimate captures the change relevant to the horizontal axis, and the identity estimate provides a measure of resemblance to the original subject. Other defects, such as unnatural changes to hair, clothing, or background, may be visible without being fully reflected by either measure. The visual comparisons complement the curves by showing features those scores leave implicit. They give examples of what can happen, with broader frequency left unmeasured.
The measured editability results also concern selected facial attributes and editing methods. The authors show additional edits involving age, makeup, hairstyles, cars, and wild animals. Those demonstrations widen the range of examples but provide a different kind of evidence from the quantified pose and smile comparisons. Compatibility with the editors shown is supported. The full range of useful directions after generator adjustment remains an open question.
Limits of the architectural and transfer claims
The architecture starts from a pretrained encoder and generator. If the initial code misses a coarse aspect of the image, the available corrections are still restricted to medium and fine feature-space convolutions. The final configuration works well in the reported facial comparisons, where the authors say the initialization tends to capture coarse detail. The evidence for its layer choices concerns that setup. A generator with different layer roles, or an encoder whose errors are concentrated in the overall layout, could give a different pattern.
The domain-transfer demonstration also relies on a relationship between the source and target generators. The target comes from adapting a pretrained generator, and the same code can carry corresponding semantic information between them. Applying the same weight offsets has a clear meaning for those corresponding layers. The experiments illustrate this operation on related generators. Transfer across independently trained generators or substantially different architectures remains outside the demonstrated setup.
Finally, the study presents the offset structure as a workable way to distribute capacity. Its shared, per-channel design improves the reported face results against the alternatives tested. There are other ways a predictor could be made more expressive or less expensive. The paper evaluates a particular set of choices, including a factorized alternative that varies within the kernel. Its strongest design conclusion is that these simple per-channel corrections, combined with shared heads and iterative feedback, are sufficient for the observed gains.
What came after
The later citing work, InstructPix2Pix, frames image editing around following an instruction. In HyperStyle, the image pair given to the hypernetwork consists of the source and a current reconstruction, and the network predicts how to improve the inversion. The desired edit enters later through a latent manipulation. InstructPix2Pix’s stated task gives the instruction a direct role in specifying the edit. That is a connection at the level of the editing problem. The citation establishes that the later work cites HyperStyle, while the title establishes the task it addresses. Architectural inheritance or reuse of HyperStyle’s predicted weight offsets is unestablished. InstructPix2Pix
Cite
Cite as Yuval Alaluf, Omer Tov, Ron Mokady, Rinon Gal and Amit Haim Bermano. 2022. HyperStyle: StyleGAN Inversion with HyperNetworks for Real Image Editing. IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings - IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings.
@inproceedings{alaluf2022hyperstyle,
title = {{HyperStyle: StyleGAN Inversion with HyperNetworks for Real Image Editing}},
author = {Yuval Alaluf, Omer Tov, Ron Mokady, Rinon Gal and Amit Haim Bermano},
booktitle = {IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings - IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings},
year = {2022},
doi = {10.1109/cvpr52688.2022.01796},
eprint = {2111.15666},
archivePrefix = {arXiv},
url = {https://doi.org/10.1109/cvpr52688.2022.01796}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/alaluf-2022-hyperstyle-stylegan-inversion-hypernetworks-real/