Skip to content
AI360XpertBeta

FID IS KID Score Generated Images

FID and KID price how far generated features sit from real ones, while IS prices confidence plus variety on generated images alone without any real set.

FID and KID measure feature distance between real and generated crowds while IS prices confidence and variety on generated images alone
FID and KID measure feature distance between real and generated crowds while IS prices confidence and variety on generated images alone

Why Does This Exist?

Pixel comparisons cannot judge fresh images with no paired truth, yet generators still need scores for fidelity plus coverage. FID fits one Gaussian to real Inception features and one to generated features, then reports their Frechet distance, so shifted means or collapsed variety both raise the number. IS skips reals entirely and scores classifier sharpness plus label spread on generated images alone, while KID replaces the Gaussian fit with a cubic-kernel mean discrepancy that stays unbiased on small sets. Face and diffusion teams report them together because each blinds a different failure.

The general generation setup lives in image generation, the model behind the scores lives in stable diffusion, and the paired-image counterparts live in PSNR SSIM LPIPS.

Think of It Like This

Two galleries judged by one critic

Real photos hang in one gallery and generated pictures in another, and a critic reduces each picture to a taste vector. FID measures how far apart the two crowds stand, KID does the same count with fairer small-crowd math, and IS never visits the real room: it asks whether generated pictures look decisively like something and cover many styles.

Distance versus applause on the same opening night. Where it stops: a critic who loves one style applauds a gallery of identical sunsets, just as IS rewards a collapsed generator that FID and KID would expose against reals.

How It Actually Works

FID is ∥mr−mg∥2+Tr(Cr+Cg−2(CrCg)1/2)\lVert m_r - m_g \rVert^2 + \text{Tr}(C_r + C_g - 2(C_r C_g)^{1/2}) on feature means mm and covariances CC, where lower is better. IS is exp⁡(E[KL(p(y∣x)∥p(y))])\exp(\mathbb{E}[\text{KL}(p(y|x) \parallel p(y))]), where sharp per-image labels plus a uniform aggregate push it higher. KID is a squared maximum mean discrepancy with a cubic polynomial kernel, lower is better and unbiased for small NN. All three demand identical preprocessing, backbone weights, and sample sizes, or the comparison misleads by points.

Worked example

Take one-dimensional features with real mean mr=0m_r = 0, generated mean mg=2m_g = 2, and unit variances Cr=Cg=1C_r = C_g = 1. The mean term is (0−2)2=4(0 - 2)^2 = 4 and the trace term is 1+1−2×1=01 + 1 - 2 \times 1 = 0, so the toy FID is 4+0=4.04 + 0 = 4.0. Closing the mean gap to 0.50.5 drops the score to (0−0.5)2=0.25(0 - 0.5)^2 = 0.25, showing mean shift dominates here. A collapsed generator with identical means but zero variance would still score through the trace term, which is why fidelity and diversity read together.

Code

The point of this snippet is the mean-term arithmetic, not a metric library: pure Python recomputes both worked scores with the standard library only.

def toy_fid(mr, mg):    return round((mr - mg) ** 2, 3)  # trace cancels at unit variance

print(toy_fid(0.0, 2.0), toy_fid(0.0, 0.5))# -> 4.0 0.25

A mean gap of 2 gives 4.0 and a gap of 0.5 gives 0.25, exactly the numbers the prose derived by hand.

Watch Out For

Comparing FIDs across different setups

The symptom is a leaderboard claim that vanishes on rerun because backbone, resize, compression, or sample count shifted the score by points. Fix it by freezing implementation, preprocessing, and NN before comparing any two numbers.

Reading IS alone as image quality

The symptom is a high IS on a generator that repeats one crisp image per class, since sharpness plus spread never checks against reals. Fix it by pairing every IS with FID or KID, which penalize the missing coverage the applause metric cannot see.

The Quick Version

  • FID is the Frechet distance between real and generated feature Gaussians, lower is better.
  • IS exponentiates label sharpness plus spread on generated images alone, higher is better.
  • KID is an unbiased kernel distance, lower is better on small sample sizes.
  • Toy means 0 versus 2 at unit variance give FID 4.04.0, narrowing to 0.5 gives 0.250.25.
  • Match code, preprocessing, and sample size before comparing any scores.