Fréchet inception distance

From HandWiki
Short description: Metric used to assess image quality

The Fréchet inception distance (FID) is a metric used to assess the quality of images created by a generative model, like a generative adversarial network (GAN).[1] Unlike the earlier inception score (IS), which evaluates only the distribution of generated images, the FID compares the distribution of generated images with the distribution of a set of real images ("ground truth").[1]

The FID metric was introduced in 2017,[1] and is the current standard metric for assessing the quality of generative models as of 2020. It has been used to measure the quality of many recent models including the high-resolution StyleGAN1[2] and StyleGAN2[3] networks.

Definition

For any two probability distributions [math]\displaystyle{ \mu, \nu }[/math] over [math]\displaystyle{ \R^n }[/math] having finite mean and variances, their Fréchet distance is[4][math]\displaystyle{ d_F (\mu, \nu):=\left( \inf_{\gamma \in \Gamma (\mu, \nu)} \int_{\R^n \times \R^n} \|x-y\|^2 \, \mathrm{d} \gamma (x, y) \right)^{1/2}, }[/math]where [math]\displaystyle{ \Gamma(\mu, \nu) }[/math] is the set of all measures on [math]\displaystyle{ \R^n \times \R^n }[/math] with marginals [math]\displaystyle{ \mu }[/math] and [math]\displaystyle{ \nu }[/math] on the first and second factors respectively. (The set [math]\displaystyle{ \Gamma(\mu,\nu) }[/math] is also called the set of all couplings of [math]\displaystyle{ \mu }[/math] and [math]\displaystyle{ \nu }[/math].). In other words, it is the 2-Wasserstein distance on [math]\displaystyle{ \R^n }[/math].

For two multidimensional Gaussian distributions [math]\displaystyle{ \mathcal{N}(\mu,\Sigma) }[/math] and [math]\displaystyle{ \mathcal{N}(\mu',\Sigma') }[/math], it is explicitly solvable as[5][math]\displaystyle{ d_{F}(\mathcal N(\mu, \Sigma), \mathcal N(\mu', \Sigma'))^2 = \lVert \mu - \mu' \rVert^2_2 + \operatorname{tr}\left(\Sigma + \Sigma' -2\left(\Sigma \Sigma' \right)^\frac{1}{2} \right) }[/math]This allows us to define the FID in pseudocode form:

INPUT a function [math]\displaystyle{ f: \Omega_X \to \R^n }[/math].

INPUT two datasets [math]\displaystyle{ S, S'\subset \Omega_X }[/math].

Compute [math]\displaystyle{ f(S), f(S') \subset \R^n }[/math].

Fit two gaussian distributions [math]\displaystyle{ \mathcal N(\mu, \Sigma), \mathcal N(\mu', \Sigma') }[/math], respectively for [math]\displaystyle{ f(S), f(S') }[/math].

RETURN [math]\displaystyle{ d_{F}(\mathcal N(\mu, \Sigma), \mathcal N(\mu', \Sigma'))^2 }[/math].

In most practical uses of the FID, [math]\displaystyle{ \Omega_X }[/math] is the space of images, and [math]\displaystyle{ f }[/math] is an Inception v3 model trained on the ImageNet, but without its final classification layer. Technically, it is the 2048-dimensional activation vector of its last pooling layer. Of the two datasets [math]\displaystyle{ S, S' }[/math], one of them is a reference dataset, which could be the ImageNet itself, and the other is a set of images generated by a generative model, such as GAN, or diffusion model.[1]

Interpretation

Rather than directly comparing images pixel by pixel (for example, as done by the L2 norm), the FID compares the mean and standard deviation of the deepest layer in Inception v3. These layers are closer to output nodes that correspond to real-world objects such as a specific breed of dog or an airplane, and further from the shallow layers near the input image.

Variants

Specialized variants of FID have been suggested as evaluation metric for music enhancement algorithms as Fréchet Audio Distance (FAD),[6] for generative models of video as Fréchet Video Distance (FVD),[7][unreliable source?] and for AI-generated molecules as Fréchet ChemNet Distance (FCD).[8]

Limitations

Chong and Forsyth[9] showed FID to be statistically biased, in the sense that their expected value over a finite data is not their true value. Also, because FID measured the Wasserstein distance towards the ground-truth distribution, it is inadequate for evaluating the quality of generators in domain adaptation setups, or in zero-shot generation. Finally, while FID is more consistent with human judgement than previously used inception score, there are cases where FID is inconsistent with human judgment (e.g. Figure 3,5 in Liu et al.).[10]

See also

References

  1. 1.0 1.1 1.2 1.3 Heusel, Martin; Ramsauer, Hubert; Unterthiner, Thomas; Nessler, Bernhard; Hochreiter, Sepp (2017). "GANs Trained by a Two Time-Scale Update Rule Converge to a Local Nash Equilibrium" (in en). Advances in Neural Information Processing Systems 30. https://papers.nips.cc/paper/2017/hash/8a1d694707eb0fefe65871369074926d-Abstract.html. 
  2. Karras, Tero; Laine, Samuli; Aila, Timo (2020). "A Style-Based Generator Architecture for Generative Adversarial Networks". IEEE Transactions on Pattern Analysis and Machine Intelligence PP (12): 4217–4228. doi:10.1109/TPAMI.2020.2970919. PMID 32012000. 
  3. Karras, Tero; Laine, Samuli; Aittala, Miika; Hellsten, Janne; Lehtinen, Jaakko; Aila, Timo (23 March 2020). "Analyzing and Improving the Image Quality of StyleGAN". arXiv:1912.04958 [cs.CV].
  4. Fréchet., M (1957). "Sur la distance de deux lois de probabilité.". C. R. Acad. Sci. Paris 244: 689–692. 
  5. Dowson, D. C; Landau, B. V (1 September 1982). "The Fréchet distance between multivariate normal distributions" (in en). Journal of Multivariate Analysis 12 (3): 450–455. doi:10.1016/0047-259X(82)90077-X. ISSN 0047-259X. 
  6. Kilgour, Kevin; Zuluaga, Mauricio; Roblek, Dominik; Sharifi, Matthew (2019-09-15). "Fréchet Audio Distance: A Reference-Free Metric for Evaluating Music Enhancement Algorithms". Interspeech 2019: 2350–2354. doi:10.21437/Interspeech.2019-2219. 
  7. Unterthiner, Thomas; Steenkiste, Sjoerd van; Kurach, Karol; Marinier, Raphaël; Michalski, Marcin; Gelly, Sylvain (2019-03-27) (in en). FVD: A new Metric for Video Generation. https://openreview.net/forum?id=rylgEULtdN. 
  8. Preuer, Kristina; Renz, Philipp; Unterthiner, Thomas; Hochreiter, Sepp; Klambauer, Günter (2018-09-24). "Fréchet ChemNet Distance: A Metric for Generative Models for Molecules in Drug Discovery". Journal of Chemical Information and Modeling 58 (9): 1736–1741. doi:10.1021/acs.jcim.8b00234. PMID 30118593. 
  9. Chong, Min Jin; Forsyth, David (2020-06-15). "Effectively Unbiased FID and Inception Score and where to find them". arXiv:1911.07023 [cs.CV].
  10. Liu, Shaohui; Wei, Yi; Lu, Jiwen; Zhou, Jie (2018-07-19). "An Improved Evaluation Framework for Generative Adversarial Networks". arXiv:1803.07474 [cs.CV].