Rakshith Subramanyam
← all writing
Paper Jul 17, 2022 2 min read

SPHInX: StyleGAN inversion for out-of-distribution images

ICML 2022, Spotlight · Paper · Code · Talk

Rakshith Subramanyam, Vivek Narayanaswamy, Mark Naufel, Andreas Spanias, Jayaraman J. Thiagarajan

A pre-trained StyleGAN-v2 is a powerful image prior. If you can find the latent code that reproduces an image (inversion), you can denoise it, recover it from a few measurements, or edit it semantically. That works well for images like the generator’s training data, such as FFHQ faces. For out-of-distribution images, faces in the wild, retina scans, skin lesions or X-rays, existing inversion methods produce poor reconstructions or brittle latents that fall apart under small perturbations.

The idea

SPHInX (StyleGAN with Projection Heads for Inverting X) learns small networks around a frozen StyleGAN instead of optimizing a single latent code:

  1. Style projection head. Replaces StyleGAN’s mapping network. A shared bottleneck (512 to 256 to 16) feeds a separate small decoder for each of the 18 style layers, which decouples the layers of the W+ latent space.
  2. Vicinal regularization. Every iteration samples a fresh noise input, so the head learns a whole neighborhood of latents that map to the image, not one fragile point. That is what makes the result robust to perturbation and usable for editing.
  3. Optional content head and noise. A small convolutional head can replace StyleGAN’s constant input, and per-layer noise can be optimized, for images far from faces.

Training uses MSE plus LPIPS for 10,000 iterations per image with the FFHQ 1024×1024 generator kept frozen.

Morphing between inverted images

What it does

  • Faces in the wild: under rotation, scaling and translation, SPHInX gives higher PSNR than Image2StyleGAN, pSp, BDInvert and other inversion methods in every setting.
  • Non-face images with a face GAN: on AFHQ animals, diabetic retinopathy scans, ISIC skin lesions and MIMIC chest X-rays it beats the baselines on both PSNR and LPIPS.
  • Restoration: it denoises non-face images using only the face prior, and recovers medical images from 1–5% of random measurements at around 34 dB PSNR.
  • Editing: it supports semantic edits and interpolation on images from new domains, such as cartoons.

Rotation edit after inversion

Why it matters

Strong generative priors are only useful if they hold up on data they weren’t trained on. SPHInX was my first paper on that theme, making a model behave sensibly out of distribution, which the rest of my PhD kept coming back to.