Generative Vision

StyleGAN

NVIDIA's family of style-based GAN generators, in which a mapping network turns the latent code into per-layer styles that modulate every convolution; the original StyleGAN (2019), StyleGAN2's weight demodulation and path length regularization, adaptive discriminator augmentation for small datasets, alias-free StyleGAN3, and StyleGAN-XL.

advanced

StyleGAN is a family of generative adversarial network generators from NVIDIA for unconditional image generation. Introduced by Karras, Laine and Aila (CVPR 2019), it changed only the generator: a mapping network turns the latent code into an intermediate code that sets the “style” of every convolution layer, and per-pixel noise supplies stochastic detail. StyleGAN2 (2020), StyleGAN2-ADA (2020), StyleGAN3 (2021) and StyleGAN-XL (2022, from another group) followed. They produce 1024×10241024 \times 1024 faces in one pass and are widely used for editing images through a GAN’s latent space.

Problem Addressed

In Progressive GANs (Karras et al., 2018) the latent code entered only through the input layer, and its space had to follow the training data’s density. Karras, Laine and Aila argued that this forces entanglement: if a combination of attributes is missing from the data, the mapping from a Gaussian zz must warp to avoid it (their Figure 6), and interpolations can show features that neither endpoint has. They sought controls separating coarse attributes (pose, identity) from stochastic ones (hair placement), and metrics for this.

Architecture

In the generator G=g∘fG = g \circ f, the mapping network f:Z→Wf: \mathcal{Z} \to \mathcal{W}, an 8-layer MLP, maps z∈R512z \in \mathbb{R}^{512} to w∈R512w \in \mathbb{R}^{512}. The synthesis network gg has 18 layers, two per resolution from 424^2 to 102421024^2; the generator has 26.2M parameters against 23.1M for the traditional one (Figure 1). The discriminator and loss are unchanged.

Styles and AdaIN

A learned affine transform of ww gives each layer a style y=(ys,yb)y = (y_s, y_b) that drives adaptive instance normalization (AdaIN), borrowed from feed-forward style transfer (Huang & Belongie, 2017). Each feature map xix_i is normalized over its spatial positions, then scaled and shifted (Eq. 1):

AdaIN(xi,y)=ys,i xi−μ(xi)σ(xi)+yb,i\mathrm{AdaIN}(x_i, y) = y_{s,i} \, \frac{x_i - \mu(x_i)}{\sigma(x_i)} + y_{b,i}

Because normalization erases the previous statistics, each style controls one convolution before the next AdaIN overrides it, which localizes control to a scale. Unlike batch normalization, which the networks do not use (Appendix C, arXiv v3), the statistics are per image.

Constant Input and Noise

Once styles were added, feeding the latent to the first layer no longer helped, so synthesis starts from a learned 4×4×5124 \times 4 \times 512 constant. After each convolution a single-channel Gaussian noise image, scaled per feature map by learned factors, is added. It changes freckles, hair placement and background texture but not identity or pose (§3.2); without it images look featureless and “painterly” (Figure 5).

Style Mixing

Mixing regularization generates some training images from two latents, w1w_1 before a random crossover layer and w2w_2 after, so that adjacent styles cannot rely on being correlated. Copying coarse styles (424^2–828^2) from another image transfers pose, face shape and glasses; middle styles (16216^2–32232^2) finer facial features; fine styles (64264^2–102421024^2) mainly color scheme and microstructure (Figure 3).

Training

StyleGAN keeps the Progressive GAN setup, including progressive growing. On FFHQ it uses the non-saturating loss with R1 regularization, a gradient penalty on real images (Mescheder, Geiger & Nowozin, 2018, Eq. 9):

R1=γ2 Ex∼pdata[∥∇xD(x)∥2]R_1 = \frac{\gamma}{2} \, \mathbb{E}_{x \sim p_{\text{data}}} \left[ \lVert \nabla_x D(x) \rVert^2 \right]

with γ=10\gamma = 10, for 25 million images, and a 100 times lower learning rate for the mapping network; training took about a week on eight V100 GPUs (Appendix C, arXiv v3; the CVPR version has no appendices). Mixing was applied to 90% of images (Table 2).

The authors released FFHQ, 70,000 aligned 1024×10241024 \times 1024 Flickr faces with more variation in age, ethnicity and background than CelebA-HQ (Appendix A, arXiv v3); the image generation article covers its licence and biases.

Inference

The truncation trick in W\mathcal{W} pulls each code toward the center of mass wˉ=Ez[f(z)]\bar w = \mathbb{E}_z[f(z)], trading variety for quality (Appendix B, arXiv v3):

w′=wˉ+ψ(w−wˉ),ψ<1w' = \bar w + \psi (w - \bar w), \qquad \psi < 1

At ψ=0\psi = 0 every image becomes FFHQ’s “mean face”; negative ψ\psi gives an “anti-face” with viewpoint, glasses or age flipped (Figure 8). Unlike truncating zz, which Brock et al. found suits only some networks, truncation in W\mathcal{W} seemed reliable without changing the loss; it can be limited to coarse layers. The paper’s FIDs are computed without it.

Editing and Inversion

InterFaceGAN fits a linear SVM per binary attribute and moves a latent code along the hyperplane normal nn by αn\alpha n. It found W\mathcal{W} better for editing than Z\mathcal{Z}, though W\mathcal{W} sometimes coupled attributes correlated in the data, such as age and eyeglasses (Shen et al., 2020, §3.4). GANSpace finds directions without labels, by PCA of sampled ww, and applies them to chosen layers (Härkönen et al., 2020). Editing a photograph first needs GAN inversion, finding a code that reproduces it. Image2StyleGAN optimizes a separate ww per layer, an extended space they call W+\mathcal{W}+ (Abdal, Qin & Wonka, 2019); StyleGAN2’s authors project into W\mathcal{W} itself, since W+\mathcal{W}+ can also fit images the generator could not have produced (§5).

Performance

Two new disentanglement measures need no encoder. Perceptual path length (PPL) averages, over 100,000 random paths, the LPIPS distance between images at nearby points of an interpolation, divided by ϵ2\epsilon^2 with ϵ=10−4\epsilon = 10^{-4} (Eq. 3):

lW=E[1ϵ2 d(g(lerp(f(z1),f(z2);t)),  g(lerp(f(z1),f(z2);t+ϵ)))]l_{\mathcal{W}} = \mathbb{E}\left[ \frac{1}{\epsilon^2} \, d\big( g(\mathrm{lerp}(f(z_1), f(z_2); t)),\; g(\mathrm{lerp}(f(z_1), f(z_2); t + \epsilon)) \big) \right]

Linear separability predicts each of 40 CelebA attributes, labelled by auxiliary classifiers, from the latent code with a linear SVM and reports exp⁡(∑iH(Yi∣Xi))\exp\big(\sum_i H(Y_i \mid X_i)\big). On FFHQ the traditional generator scored path length 412.0 and separability 10.78 in Z\mathcal{Z}; the style-based generator with noise, 200.5 and 3.54 in W\mathcal{W} (Table 3).

FIDs (lower is better) as printed. Protocols differ: StyleGAN reports the lowest FID over training, from 50,000 images against the training set; StyleGAN2 the lowest-FID snapshot, each metric averaged over 10 evaluations; and the CIFAR-10 figure is a mean of the best scores of five runs.

Model Source (table, version) Dataset, resolution FID
Progressive GAN baseline Karras et al. 2019, Table 1, arXiv v3 FFHQ, 102421024^2 8.04
StyleGAN (config F) Karras et al. 2019, Table 1, arXiv v3 FFHQ, 102421024^2 4.40
StyleGAN Karras et al. 2019, Figure 10, arXiv v3 LSUN Bedroom, 2562256^2 2.65
StyleGAN2 (config F) Karras et al. 2020, Table 1, arXiv v2 FFHQ, 102421024^2 2.84
StyleGAN2 (config F) Karras et al. 2020, Table 1, arXiv v2 LSUN Car, 512×384512 \times 384 2.32
StyleGAN2 + ADA, tuned Karras et al. 2020, Figure 11b, arXiv v2 CIFAR-10 class-conditional, 32232^2 2.42
StyleGAN3-T / StyleGAN3-R Karras et al. 2021, Figure 5, arXiv v4 FFHQ, 102421024^2 2.79 / 3.07
StyleGAN-XL Sauer et al. 2022, Table 2, arXiv v2 ImageNet class-conditional, 2562256^2 2.30

StyleGAN3’s own StyleGAN2 baseline, with Fourier features, scored 2.70 on FFHQ. The ADA paper’s text pairs FID 2.42 with IS 10.24, but in its table 10.24 belongs to the untuned ADA row; the tuned row with FID 2.42 prints IS 10.14.

Strengths

  • Per-layer styles give coarse-to-fine control and style mixing without labels.
  • The smoother W\mathcal{W} space supports editing, interpolation and inversion.
  • Sampling is one pass: StyleGAN-XL took 0.07 V100-seconds per 2562256^2 image against 40.26 for classifier-guided ADM, a diffusion model (Sauer et al., Table 3, arXiv v2).

Limitations

  • Domain-specific. They excel on aligned single-domain data (faces, cars, bedrooms). The StyleGAN-XL authors cite sub-par earlier attempts on ImageNet, and their StyleGAN3 baseline scored FID 53.57 on ImageNet 1282128^2 after 15 V100-days (Table 1).
  • Diversity. On ImageNet 2562256^2, StyleGAN-XL’s recall (coverage of the real images), 0.53, was below unguided ADM’s 0.63 (Table 2).
  • Misuse. The StyleGAN3 authors list disinformation among image GANs’ potential harms, note that removing artifacts can make videos more convincing, and suggest watermarking and authenticity checks (§5, arXiv v4). StyleGAN2’s own images project almost exactly into W\mathcal{W}, which helps attribute an image to its generator (§5.1).

Historical Importance

StyleGAN’s authors reported a new state of the art for unconditional generation in 2019, and its successors kept FFHQ as a main benchmark; in our reading, W\mathcal{W} started a line of work on latent editing and inversion. Diffusion models later overtook GANs on diverse datasets.

Variants

StyleGAN2 (2020)

Karras et al. traced blob-shaped “water droplet” artifacts, present in feature maps from 64×6464 \times 64 upward, to AdaIN: they hypothesize that the generator creates a strong local spike that dominates each map’s statistics, letting it scale the signal elsewhere freely. Removing normalization removed the droplets (§2). They moved bias and noise outside the style block and replaced instance normalization by weight demodulation. Modulating input map ii by sis_i equals scaling the weights (Eq. 1); for i.i.d. unit-variance inputs, output map jj then has standard deviation ∑i,kwijk′2\sqrt{\sum_{i,k} {w'_{ijk}}^2} (Eq. 2), so dividing by it restores unit variance without looking at the activations (Eq. 3):

wijk′=si wijk,wijk′′=wijk′∑i,kwijk′2+ϵw'_{ijk} = s_i \, w_{ijk}, \qquad w''_{ijk} = \frac{w'_{ijk}}{\sqrt{\sum_{i,k} {w'_{ijk}}^2 + \epsilon}}

Lazy regularization computes the regularizers in a separate pass every 16 discriminator or 8 generator minibatches (Appendix B, arXiv v2). Path length regularization pushes the Jacobian JwJ_w of gg toward orthogonality up to a global scale, with random images yy and a moving average aa of ∥Jw⊤y∥2\lVert J_w^\top y \rVert_2 (Eq. 4):

Ew, y∼N(0,I)(∥Jw⊤y∥2−a)2\mathbb{E}_{w,\, y \sim \mathcal{N}(0, I)} \left( \lVert J_w^\top y \rVert_2 - a \right)^2

Progressive growing, which left details such as teeth stuck to the camera rather than following the pose, gave way to a generator with output skips and a residual discriminator, and larger networks completed config F (Table 1).

Example: Demodulation Versus Instance Normalization

The NumPy example applies one styled 3×33 \times 3 convolution to synthetic 32×3232 \times 32 textures: white noise, meeting Eq. 2’s assumption, and box-blurred noise with correlated neighbouring pixels. A bright spike tests the droplet mechanism.

import numpy as np

def conv_valid(x, w):
    """Per-sample 3x3 'valid' convolution. x: (N, Cin, H, W); w: (N, Cout, Cin, 3, 3)."""
    N, Cin, H, W = x.shape
    patches = np.stack([x[:, :, i:H - 2 + i, j:W - 2 + j]
                        for i in range(3) for j in range(3)], axis=2)  # (N, Cin, 9, H-2, W-2)
    return np.einsum("nokl,nklhw->nohw", w.reshape(N, w.shape[1], Cin, 9), patches)

def textures(rng, N, C, H, smooth):
    """Synthetic feature maps: white pixel texture, or smooth blobs (box-blurred noise)."""
    x = rng.standard_normal((N, C, H + 8, H + 8))
    if smooth:  # 9x9 box blur: neighbouring pixels become strongly correlated
        c = np.cumsum(np.cumsum(np.pad(x, ((0, 0), (0, 0), (1, 0), (1, 0))), 2), 3)
        x = c[:, :, 9:, 9:] - c[:, :, :-9, 9:] - c[:, :, 9:, :-9] + c[:, :, :-9, :-9]
    else:
        x = x[:, :, 4:-4, 4:-4]
    return x / x.std(axis=(2, 3), keepdims=True)  # unit std per map

def inorm(y):  # instance normalization of std (StyleGAN2 Fig. 2c), uses the activations
    return y / y.std(axis=(2, 3), keepdims=True)

def run(seed, verbose):
    rng = np.random.default_rng(seed)
    N, Cin, Cout, H = 4, 16, 16, 32
    w = rng.standard_normal((Cout, Cin, 3, 3))
    s = np.exp(1.2 * rng.standard_normal((N, Cin)))      # styles from A(w): one scale per input map
    x = textures(rng, N, Cin, H, smooth=False)

    w_mod = s[:, None, :, None, None] * w[None]           # Eq. 1: w'_ijk = s_i w_ijk
    y_act = conv_valid(s[:, :, None, None] * x, np.broadcast_to(w[None], w_mod.shape))
    y_mod = conv_valid(x, w_mod)
    sigma = np.sqrt((w_mod ** 2).sum(axis=(2, 3, 4)))     # Eq. 2: predicted output std
    w_demod = w_mod / np.sqrt(sigma[:, :, None, None, None] ** 2 + 1e-8)  # Eq. 3
    y_dem = conv_valid(x, w_demod)
    y_in = inorm(y_mod)

    xs = textures(rng, N, Cin, H, smooth=True)           # assumption broken: correlated pixels
    y_dem_s = conv_valid(xs, w_demod)

    # localized spike at one pixel of sample 0, all input maps (the droplet hypothesis)
    xk = x.copy(); xk[0, :, 15, 15] += 200.0
    far = np.ones((H - 2, H - 2), bool); far[11:18, 11:18] = False  # away from the spike
    ratio_in = inorm(conv_valid(xk, w_mod))[0][:, far].std() / y_in[0][:, far].std()
    ratio_dem = conv_valid(xk, w_demod)[0][:, far].std() / y_dem[0][:, far].std()

    sd = lambda y: y.std(axis=(2, 3))
    out = dict(eq1=np.abs(y_act - y_mod).max(),
               mod=sd(y_mod), dem=sd(y_dem), inn=sd(y_in),
               dem_s=sd(y_dem_s), r_in=ratio_in, r_dem=ratio_dem)
    if verbose:
        f = lambda a: f"{a.min():7.3f} to {a.max():7.3f}"
        print(f"seed {seed}: max |modulate x, then conv  -  conv with s*w| = {out['eq1']:.1e}")
        print("per-map output std over", N, "samples x", Cout, "maps:")
        print("  modulation only              ", f(out["mod"]))
        print("  + instance norm (activations)", f(out["inn"]))
        print("  demodulated weights (Eq. 3)  ", f(out["dem"]))
        print("  demodulated, smooth inputs   ", f(out["dem_s"]))
        print("spike of 200 in sample 0: std far from the spike, relative to no spike")
        print(f"  instance norm {ratio_in:.3f}   demodulation {ratio_dem:.3f}")
    return out

run(0, verbose=True)
print("\nseeds 0-4 (ranges over seeds):")
res = [run(k, verbose=False) for k in range(5)]
for key, name in [("dem", "demod, white"), ("dem_s", "demod, smooth")]:
    print(f"  {name:14s} std {min(r[key].min() for r in res):.3f} to "
          f"{max(r[key].max() for r in res):.3f}")
for key, name in [("r_in", "instance norm"), ("r_dem", "demodulation")]:
    v = [r[key] for r in res]
    print(f"  spike ratio, {name:14s} {min(v):.3f} to {max(v):.3f}")
seed 0: max |modulate x, then conv  -  conv with s*w| = 5.7e-14
per-map output std over 4 samples x 16 maps:
  modulation only                15.398 to  46.496
  + instance norm (activations)   1.000 to   1.000
  demodulated weights (Eq. 3)     0.961 to   1.048
  demodulated, smooth inputs      0.586 to   1.698
spike of 200 in sample 0: std far from the spike, relative to no spike
  instance norm 0.159   demodulation 1.000

seeds 0-4 (ranges over seeds):
  demod, white   std 0.949 to 1.064
  demod, smooth  std 0.460 to 1.820
  spike ratio, instance norm  0.148 to 0.160
  spike ratio, demodulation   1.000 to 1.000

Styles spread output standard deviations from 15 to 46 (seed 0). Using only the weights, demodulation brings them to 0.95–1.06 on white textures over seeds 0–4, near instance normalization’s exact 1; smooth inputs, which break Eq. 2’s independence assumption, give 0.46 to 1.82: as the authors note, demodulation relies on statistical assumptions, not the feature maps. The spike is our toy version of the droplet hypothesis: under instance normalization one bright pixel shrinks the rest of the map to about 0.15 of its scale; demodulated weights ignore the activations, so the rest is unchanged by construction.

StyleGAN2-ADA (2020)

With little data the discriminator overfits and FID starts to rise, and ordinary augmentation leaks into generated images. Adaptive discriminator augmentation (Karras et al., 2020) augments every image the discriminator sees, real or generated, also when training the generator. Each of 18 transformations is applied with probability pp; many are non-leaking if skipped with nonzero probability, and leaks were unlikely in practice with pp below 0.8 (§2.2). Every four minibatches pp is adjusted so that rt=E[sign(Dtrain)]r_t = \mathbb{E}[\mathrm{sign}(D_{\text{train}})], the share of training images the discriminator scores positive, approaches a target of 0.6 (§3). On 2562256^2 FFHQ, median FID with 1,000 training images fell from 100.16 to 21.29, and with all 70,000 from 5.28 to 4.30 (Figure 7c, arXiv v2). It also released MetFaces, 1,336 faces from the Metropolitan Museum of Art.

StyleGAN3 (2021)

In StyleGAN2, fine details such as hair stick to pixel coordinates during interpolation instead of moving with surfaces: texture sticking. Karras et al. (2021) traced it to positional information from image borders, per-pixel noise and aliasing from imperfect upsampling filters and pointwise nonlinearities. Treating feature maps as samples of bandlimited continuous signals, they made every layer equivariant to sub-pixel translation: Fourier features replace the constant input, noise inputs are removed, filters are Kaiser-windowed sincs, and each leaky ReLU runs at twice the resolution between upsampling and downsampling. StyleGAN3-R adds rotation equivariance with 1×11 \times 1 convolutions and radially symmetric filters. On FFHQ, translation equivariance (EQ-T, a PSNR) rose from 13.58 dB for StyleGAN2 to 61.21 dB for StyleGAN3-T at similar FID (Figure 5, arXiv v4).

StyleGAN-XL (2022)

Sauer, Schwarz and Geiger scaled StyleGAN3-T layers to class-conditional ImageNet with Projected GAN discriminators on pretrained CNN and ViT features, a 64-dimensional zz, pretrained class embeddings, progressive growing and classifier guidance, reaching 102421024^2.

Implementations

As of October 2026, NVIDIA’s official repositories are NVlabs/stylegan (TensorFlow, CC BY-NC 4.0), NVlabs/stylegan2 and NVlabs/stylegan2-ada (TensorFlow 1.x), and NVlabs/stylegan2-ada-pytorch and NVlabs/stylegan3 (PyTorch). The last four use NVIDIA source code licences limiting use to non-commercial research or evaluation; the PyTorch version supersedes stylegan2-ada, its README says. autonomousvision/stylegan-xl has a top-level MIT licence but builds on the StyleGAN3 code, whose files keep NVIDIA’s copyright headers.

Related

  • Image Generation

    The task of producing new images from random noise, or from noise and a class label, that look as if they came from the training distribution; how it is defined, the unconditional and class-conditional variants, the benchmarks it is measured on, and its failure modes, from mode dropping to memorized training images.

  • Fréchet Inception Distance

    The standard sample-based score for image generative models, the Fréchet (2-Wasserstein) distance between Gaussians fitted to Inception-v3 features of real and generated images; its formula, its small-sample bias, its sensitivity to resizing and compression, its ImageNet bias, and the related metrics IS, KID, precision and recall, and FD-DINOv2.

  • Sampling and Aliasing

    How a continuous image becomes a grid of samples, when the samples determine it completely, and how detail too fine for the grid turns into false, coarser patterns.

  • Batch Normalization

    A layer that normalizes each channel of a feature map with the mean and variance of the current mini-batch, then rescales it with learned parameters; it allows higher learning rates in convolutional networks but depends on the batch size and behaves differently in training and inference.

  • Generative Model

    A model of the probability distribution of images that can draw new samples from it; the overview of the main families (autoregressive models, variational autoencoders, normalizing flows, GANs and diffusion models), how they differ, and how they are compared.

  • Diffusion Model

    A generative model that learns to reverse a gradual Gaussian noising of images, generating by starting from pure noise and denoising step by step; the forward and reverse processes, the noise, data and score parameterizations, the U-Net and transformer denoisers, noise schedules, conditioning and the unifying score-SDE view.

References

  1. Karras, T., Laine, S. & Aila, T. (2019). A Style-Based Generator Architecture for Generative Adversarial Networks. IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 4396–4405.
  2. Karras, T., Laine, S., Aittala, M., Hellsten, J., Lehtinen, J. & Aila, T. (2020). Analyzing and Improving the Image Quality of StyleGAN. IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 8107–8116.
  3. Karras, T., Aittala, M., Hellsten, J., Laine, S., Lehtinen, J. & Aila, T. (2020). Training Generative Adversarial Networks with Limited Data. Advances in Neural Information Processing Systems 33 (NeurIPS), 12104–12114.
  4. Karras, T., Aittala, M., Laine, S., Härkönen, E., Hellsten, J., Lehtinen, J. & Aila, T. (2021). Alias-Free Generative Adversarial Networks. Advances in Neural Information Processing Systems 34 (NeurIPS), 852–863.
  5. Sauer, A., Schwarz, K. & Geiger, A. (2022). StyleGAN-XL: Scaling StyleGAN to Large Diverse Datasets. SIGGRAPH '22 Conference Proceedings (ACM), 1–10.
  6. Karras, T., Aila, T., Laine, S. & Lehtinen, J. (2018). Progressive Growing of GANs for Improved Quality, Stability, and Variation. International Conference on Learning Representations (ICLR). arXiv:1710.10196.
  7. Huang, X. & Belongie, S. (2017). Arbitrary Style Transfer in Real-Time with Adaptive Instance Normalization. IEEE International Conference on Computer Vision (ICCV), 1510–1519.
  8. Mescheder, L., Geiger, A. & Nowozin, S. (2018). Which Training Methods for GANs do actually Converge? Proceedings of the 35th International Conference on Machine Learning (ICML), PMLR 80, 3481–3490.
  9. Abdal, R., Qin, Y. & Wonka, P. (2019). Image2StyleGAN: How to Embed Images Into the StyleGAN Latent Space? IEEE/CVF International Conference on Computer Vision (ICCV), 4431–4440.
  10. Shen, Y., Gu, J., Tang, X. & Zhou, B. (2020). Interpreting the Latent Space of GANs for Semantic Face Editing. IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 9240–9249.
  11. Härkönen, E., Hertzmann, A., Lehtinen, J. & Paris, S. (2020). GANSpace: Discovering Interpretable GAN Controls. Advances in Neural Information Processing Systems 33 (NeurIPS), 9841–9850.