To edit a real photograph with a pretrained image generator such as StyleGAN, you first need an encoder that maps the photo into the generator's latent space, the compact code the generator turns into an image. You then move that code along a direction that changes one attribute, such as age or pose, and decode it. Codes that edit well tend to reconstruct poorly: glasses, hair strands and backgrounds go missing. One fix is to split the job in two. ReGANIE inverts the image into an editable code and then runs a second "rectifier" network. The rectifier sees the pixel difference between the photo and its reconstruction and paints the lost detail back in. This two-stage pipeline gets close to optimization-level fidelity in about 190 ms. Its encoder, however, is still a large network, and the question of how to shrink it has not been asked.
The proposal is that once a rectifier is present, the encoder has a different job, so it should be compressed with a different objective. The rectifier can repair local, high-frequency errors because it sees the pixel residual. It cannot repair errors in pose, global shape or semantic attributes, and ReGANIE itself reports that its rectifier struggles under large geometric changes. We therefore propose to distill a small student encoder from a large teacher encoder with a loss that measures latent error only in the directions the downstream rectifier cannot undo. Student capacity then goes to geometry and semantics. Detail is left to the rectifier, which is retrained on the student's own residuals. The testable prediction is that, at a fixed small size, this student matches the teacher pipeline's editing accuracy and identity preservation. A student distilled with uniform latent matching, or trained from scratch, should not.
Core Claim
Knowledge distillation trains a small "student" network to imitate a large "teacher." Latent distillation for image coders, as in Compressing image encoders via latent distillation, freezes the decoder and trains a narrow student encoder to match the teacher's latent codes by plain mean squared error. That work cut computation 35x and still beat students trained from scratch, even with 0.1% of the training data. It treats every latent dimension as equally important because its decoder has no side information. In a decoupled inversion–rectification pipeline that assumption is wrong. Some latent errors are cheap because the rectifier erases them. Others are expensive because they move the face, change identity, or corrupt the edit directions.
We make this concrete with a rectifier-aware distillation metric. Let $w_T(x)$ and $w_S(x)$ be the teacher and student codes for image $x$. Let $R$ be the frozen teacher rectifier, which takes a generated image and the residual $\Delta X = x - G(w)$ from the frozen generator $G$. Let $d$ be an edit direction with strength $\alpha$. We estimate a positive semi-definite matrix $M$ from the Jacobian $J$ of the edited, rectified output $R(G(w+\alpha d), \Delta X(w))$ with respect to $w$, averaged over training images, edit directions and strengths:
$$ M = \mathbb{E}_{x,d,\alpha}\left[J^\top J\right], \qquad \mathcal{L}_{\text{distill}} = (w_S - w_T)^\top M \,(w_S - w_T) + \lambda \lVert w_S - w_T \rVert^2 . $$
Here $\lambda$ is a small uniform term that keeps the student inside the editable region. $M$ is large along directions where a latent error survives rectification and editing, and near zero where the rectifier absorbs it. It is a Fisher-style metric of the kind used to weight parameters by importance, but defined through the rectifier. We compute it per layer of the layered latent space using random-probe Jacobian-vector products on a few thousand images, once, before student training.
Research Program
The teacher pipeline is a standard editable encoder followed by a ReGANIE-style spatial-and-global rectifier over a frozen StyleGAN2 trained on FFHQ. ReGANIE uses an e4e encoder of this kind. We will first measure where the teacher rectifier fails. We perturb teacher codes along principal directions, known attribute directions and pose directions, and record how much edited-output error remains after rectification. This produces $M$. It also tests the premise directly: if $M$ turns out nearly isotropic, the claim is wrong and uniform latent distillation is already the right answer.
Next, we distill student encoders at 1/2, 1/4 and 1/8 of the teacher's width using $\mathcal{L}_{\text{distill}}$, with the generator frozen and no pixel loss on the encoder. Following the latent distillation paper, we also run a low-data regime of 0.1% and 1% of FFHQ. Then we fine-tune the rectifier on residuals produced by the student rather than the teacher. The student's errors are larger and differently structured, and a rectifier trained on teacher residuals may never have seen them. As a secondary step, we compress the rectifier itself by output distillation from the fine-tuned teacher rectifier. Encoder and rectifier costs are reported separately from the frozen generator, which neither method changes.
We keep the rectifier deterministic and avoid distribution-matching decoders such as the one-step diffusion student in SSDD. In editing, unedited regions should stay pixel-faithful. SSDD itself accepts lower PSNR in exchange for realism, and that tradeoff is the tension the research file flags between SSDD-style decoders and the distortion-minimizing goals of ReGANIE and ID-attribute decoupled inversion. A one-step diffusion rectifier is a natural follow-up only if the deterministic one proves blurry on hallucinated regions.
Relation to Prior Work
The work that motivates this proposal is the decoupling line. ReGANIE shows that a residual-conditioned rectifier can carry the fidelity burden. Editable GAN shows that separating the image-to-latent mapping from the generator protects generation quality. The tokenizer papers make a related argument for generative learnability: SeQ-GAN, DiGIT and MAETok all hold that latents should carry semantics while a separate decoder handles detail. None of these papers compresses the semantic encoder. MAETok distills from DINOv2 and CLIP into a full-size encoder rather than into a smaller one.
The work that supplies the method is latent distillation, whose frozen-decoder recipe we reuse. We replace its uniform metric with one derived from the rectifier. SSDD shows the mirror case, freezing the encoder and distilling the decoder. Neither paper considers a pipeline whose second stage sees the input residual, and that residual is what makes some encoder errors free.
The work that constrains the design is ReGANIE's own reported weakness under large geometric change. It tells us the rectifier cannot be trusted with pose, so pose must be handled by the encoder. Optimization-based inversion, such as WRanGAN, serves as an accuracy ceiling rather than a competitor, since it needs per-image gradient steps.
Baselines
The naive reference point is the uncompressed teacher pipeline, a full-size editable encoder plus a full-size rectifier. ReGANIE reports L2 distance 0.016 and LPIPS 0.07 on its face benchmarks at roughly 190 ms end to end. We will rerun it on our splits rather than rely on those numbers. A student counts as successful if, at 1/4 width or smaller, it stays within the teacher's run-to-run variation on edit attribute accuracy and identity similarity, and within a small margin on L2 and LPIPS. The second reference point is the student encoder with no rectifier. It shows how much of the compression loss the rectifier recovers at all.
The strongest existing compression method is uniform-MSE latent distillation from Compressing image encoders via latent distillation. That paper reports a 35x MAC reduction at 1/8 width. It reports no numbers for face inversion or editing, so no reported result was found on Lacuna for this method on FFHQ or CelebA-HQ. We will run it with the same student architectures, data, rectifier fine-tuning and tuning budget as our method, with the same number of hyperparameter trials for its single loss weight as we give $\lambda$. Beating it means lower pose error and higher edit accuracy and identity similarity at equal MACs, with reconstruction distortion no worse.
Two ablations isolate the ingredients. The first swaps our metric $M$ for the identity matrix, which reduces to the uniform baseline, and for a random matrix of matched spectrum. This separates the effect of which directions are weighted from the effect of merely reweighting. The second keeps our metric but freezes the teacher-trained rectifier instead of fine-tuning it on student residuals. It tests whether residual distribution shift matters. As an accuracy ceiling rather than a target, we report WRanGAN, whose paper gives FFHQ MSE 0.007, against 0.024 for PTI.
Why not just…?
Why not just shrink the encoder and train it from scratch with the usual inversion losses? The latent distillation paper found that scratch-trained narrow encoders were unstable and far worse than distilled ones. That finding comes from compression models without a rectifier, though. It is a real possibility that a rectifier makes encoder quality matter so little that even a scratch-trained student suffices. We include this as a full baseline at every width and data fraction. If it matches our method on edit accuracy and pose error, the rectifier-aware metric is unnecessary, and we would report that.
Why not just distill the whole pipeline on its final output pixels? Matching the teacher's rectified images end to end is simpler. It places no constraint on where the student's code lands, however, so the student is free to push detail into the latent. The tokenizer literature (SeQ-GAN) shows that a detail-crammed latent is harder to model downstream, and ReGANIE's design premise is that a detail-crammed latent edits worse. We run output-level distillation with the same budget and measure edit accuracy separately from reconstruction. The prediction is good reconstruction with degraded edits. If edits hold up, this alternative wins.
Why not just keep the full encoder and use per-image optimization for fidelity? Optimization gives the best distortion: WRanGAN reports 0.007 MSE. ReGANIE reports that PTI-style tuning takes over a minute per image, against about 190 ms for the feed-forward pipeline, and even WRanGAN is only 1.5–2x faster than PTI. For interactive or on-device editing this does not compete. We report it as a ceiling, not as the target.
Proposed Experiments
We train on FFHQ and test on CelebA-HQ for in-domain inversion and editing, and on MetFace for out-of-domain fidelity, matching ReGANIE's evaluation. Metrics are L2, LPIPS and PSNR for reconstruction, identity similarity for identity preservation, and attribute-classifier accuracy for edits. We also report encoder and rectifier MACs, parameter storage, and per-component latency.
The first decisive check is a large-yaw subset of CelebA-HQ, grouped into bins of estimated head pose. There we measure pose error of the inverted code and identity similarity after pose edits. The rectifier-aware student should hold up where the uniform student degrades, because pose is exactly what the rectifier cannot repair.
The second decisive check is a correlation analysis across all students. If the thesis is right, final edit quality should track student error measured under $M$ much more closely than it tracks plain latent MSE. If both predict equally well, the metric adds nothing.
The third check is the low-data regime, 0.1% of FFHQ, to see whether the data efficiency reported for latent distillation carries over when a rectifier is present.
A negative outcome on the first two checks would be informative on its own: it would mean that in decoupled pipelines encoder errors matter uniformly and the standard distillation recipe is already sufficient.
References
- ReGANIE: Rectifying GAN Inversion Errors for Accurate Real Image Editing
- Compressing image encoders via latent distillation
- SSDD: Single-Step Diffusion Decoder for Efficient Image Tokenization
- Zero-shot Face Editing via ID-Attribute Decoupled Inversion
- Editable Generative Adversarial Networks: Generating and Editing Faces Simultaneously
- Rethinking the Objectives of Vector-Quantized Tokenizers for Image Synthesis
- Stabilize the Latent Space for Image Autoregressive Modeling: A Unified Perspective
- Masked Autoencoders Are Effective Tokenizers for Diffusion Models
- Robust GAN inversion