Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Grading a model that makes pictures
Grading a generator is like judging an art forger. Are the forgeries convincing one by one? Do they cover the whole range of the artist’s work, or only one favourite subject? If you asked for a particular scene, did you get it? No single number answers all three questions, so practitioners use several: some summarise everything in one distance, others split realism from variety. The demo compares a real and a generated bell curve and shows how one distance can hide which of the two went wrong.
Synthetic satellite or SAR images used to train detectors must be judged on coverage of rare scenes, not just realism; a generator that only makes easy scenes looks good on realism alone.
- 1. Fidelity means samples are…
- 2. Diversity means samples…
- 3. CLIP score measures…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Likelihood (bits/dim): exact or bounded test NLL; the right metric for compression and density estimation, weakly related to sample quality.
- Inception score (Salimans et al., 2016): IS = exp(E_x KL(p(y | x) ‖ p(y))) with an ImageNet Inception-v3 classifier; high when each sample is confidently one class and classes are spread. Blind to diversity within a class and to the real data.
- FID (Heusel et al., 2017): fit Gaussians to 2048-D Inception pool features of real and generated images; FID = ‖μ_r − μ_g‖² + tr(Σ_r + Σ_g − 2(Σ_r Σ_g)^½). The standard metric; biased upward at small n, so report at fixed n (typically 50000).
- KID (Bińkowski et al., 2018): unbiased MMD² with the cubic polynomial kernel; meaningful at small n, reported with a standard deviation over subsets.
- Precision and recall (Sajjadi et al., 2018; Kynkäänniemi et al., 2019): k-NN balls around real points define the real manifold; precision = share of generated samples inside it, recall = share of real samples inside the generated manifold. Density and coverage (Naeem et al., 2020) are more robust variants.
- CLIP score (Hessel et al., 2021): 100 × cosine between CLIP image and text embeddings; used with FID to trace the guidance trade-off in text-to-image models.
- Today (2026): FID computed on DINOv2 features (FD-DINOv2, Stein et al., 2023) tracks human judgement better than Inception FID; CMMD uses CLIP embeddings with MMD; human preference models and arena-style ratings are standard for text-to-image and video.
- 1. FID compares…
- 2. KID is preferred at small n because…
- 3. IS ignores…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Computing the metrics
Exercise 1.
- FID from feature means and covariances.
- KID as an unbiased cubic-kernel MMD².
- The Inception score from class probabilities.
- k-NN precision and recall.
Practice.
- Use a standard implementation (clean-fid, torchmetrics, torch-fidelity) so that resizing and JPEG handling match published numbers.
- Report FID at a fixed sample count (50k for ImageNet-scale) against a fixed reference set; give KID with its standard deviation.
- Always pair FID with precision/recall, or with a human study.
- For text-to-image, plot FID vs CLIP score across guidance scales rather than single points.
- Check for memorisation: nearest-neighbour distances from samples to the training set.
from cleanfid import fid
score = fid.compute_fid("real_images/", "generated_images/", mode="clean", num_workers=8)
kid = fid.compute_kid("real_images/", "generated_images/")
from torchmetrics.multimodal.clip_score import CLIPScore
clip = CLIPScore(model_name_or_path="openai/clip-vit-base-patch16")
print(score, kid, clip(images_uint8, prompts))- 1. Report FID at…
- 2. A library that standardises FID preprocessing:
- 3. Trace the guidance trade-off with…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
FID is the 2-Wasserstein distance between Gaussians. For N(μ₁, Σ₁) and N(μ₂, Σ₂), W₂² = ‖μ₁ − μ₂‖² + tr(Σ₁ + Σ₂ − 2(Σ₁^½ Σ₂ Σ₁^½)^½); the trace of that root equals Σ √λᵢ(Σ₁Σ₂). In 1-D it is (m₁ − m₂)² + (s₁ − s₂)², so a shift and a change of spread are indistinguishable.
Bias. Plug-in estimates of μ and Σ from n samples make E[FID] exceed the true value by roughly O(d/n), even for a perfect generator; ranking models evaluated at different n is meaningless. KID’s U-statistic is unbiased.
Inception score. IS = exp(I(y; x)) under the generator, the mutual information between image and predicted class, so 1 ≤ IS ≤ number of classes. It is maximal for one perfect image per class: it rewards mode collapse within classes.
Precision/recall. Splitting the single distance into two numbers separates truncation (high precision, low recall) from noisy samples (low precision, high recall). k-NN balls overestimate the manifold near outliers, the motivation for density and coverage.
| flaw | FID | IS | precision | recall |
|---|---|---|---|---|
| dropped classes | up | down | unchanged | down |
| low diversity | up | up | up | down |
| low fidelity | up | slightly down | down | unchanged |
- 1. In 1-D, FID equals…
- 2. The maximum IS with 1000 classes is…
- 3. Truncation sampling raises…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.Do FID, KID, IS and precision/recall each detect dropped modes, low diversity and low fidelity, and how much do they depend on sample size?
History.
- T. Salimans et al., “Improved techniques for training GANs” (2016): the Inception score.
- M. Heusel et al., “GANs trained by a two time-scale update rule converge to a local Nash equilibrium” (2017): FID.
- M. Bińkowski et al., “Demystifying MMD GANs” (2018): KID. M. Sajjadi et al. (2018) and T. Kynkäänniemi et al. (2019): precision and recall.
- J. Hessel et al., “CLIPScore” (2021); G. Stein et al., “Exposing flaws of generative model evaluation metrics” (2023); S. Jayasumana et al., “Rethinking FID” (CMMD, 2024).
Exercise 2. Real “features” are a 10-class Gaussian mixture in 16 dimensions; the true class posterior plays the Inception classifier. Each generator has one flaw; 1000 samples per set.
- perfect: same distribution; mode drop: only 5 classes; low diversity: within-class std 0.5 instead of 1; low fidelity: extra noise of std 1.
- Sample size: FID and KID for two independent sets from the perfect generator at n = 50, 200, 1000.
| generator | FID | KID | IS | precision | recall |
|---|---|---|---|---|---|
| perfect | 0.32 | 0.002 | 9.49 | 0.780 | 0.807 |
| mode drop | 5.43 | 1.293 | 5.27 | 0.784 | 0.492 |
| low diversity | 2.54 | 0.108 | 9.92 | 1.000 | 0.036 |
| low fidelity | 2.43 | 0.199 | 8.88 | 0.244 | 0.994 |
| n (perfect vs perfect) | FID | KID |
|---|---|---|
| 50 | 5.56 | −0.289 |
| 200 | 1.60 | 0.003 |
| 1000 | 0.24 | −0.017 |
- FID detected every flaw but could not say which: low diversity and low fidelity scored 2.54 and 2.43.
- Precision/recall named the flaw: 1.00/0.04 for low diversity, 0.24/0.99 for low fidelity, and recall fell to 0.49 when half the classes were dropped.
- IS rewarded the flaw: the low-diversity generator beat real data (9.92 vs 9.44); dropped classes were the only flaw it penalised strongly.
- Sample size: a perfect generator at n = 50 had a worse FID (5.56) than the mode-dropping generator at n = 1000; KID stayed centred on zero but was noisy at n = 50.
- Seeds 1 and 2: low diversity vs low fidelity FID 2.61 vs 2.27 and 2.56 vs 2.41; low-diversity IS 9.86 and 9.96 vs real 9.45 and 9.61; FID at n = 50 5.84 and 5.76.
- Caveat: Gaussian features with a known classifier; real Inception features are not Gaussian, which adds further bias to FID.
Generative evaluation in AI, robotics and aerospace
- Synthetic training data: the final test is downstream: detector or segmenter accuracy when trained with generated data.
- Domain features: for satellite, SAR or medical images, Inception features are poorly suited; use domain encoders (for example remote-sensing foundation models) for FID-style metrics.
- Text-to-image and video: FID or FD-DINOv2 with CLIP score and human preference ratings is the norm.
References
- T. Salimans et al. (2016). “Improved techniques for training GANs.” NeurIPS.
- M. Heusel et al. (2017). “GANs trained by a two time-scale update rule converge to a local Nash equilibrium.” NeurIPS.
- M. Bińkowski, D. J. Sutherland, M. Arbel and A. Gretton (2018). “Demystifying MMD GANs.” ICLR.
- T. Kynkäänniemi et al. (2019). “Improved precision and recall metric for assessing generative models.” NeurIPS.
- J. Hessel et al. (2021). “CLIPScore: a reference-free evaluation metric for image captioning.” EMNLP.
- G. Stein et al. (2023). “Exposing flaws of generative model evaluation metrics and their unfair treatment of diffusion models.” NeurIPS.