Package for calculating Frechet Inception Distance (FID) using PyTorch
Slowing down. Last release over 3 years ago, little activity since. Fine for existing code; think twice for a new project.
pip install pytorch-fidFID score for PyTorch
This is a port of the official implementation of Fréchet Inception Distance to PyTorch. See https://github.com/bioinf-jku/TTUR for the original implementation using Tensorflow.
FID is a measure of similarity between two datasets of images. It was shown to correlate well with human judgement of visual quality and is most often used to evaluate the quality of samples of Generative Adversarial Networks. FID is calculated by computing the Fréchet distance between two Gaussians fitted to feature representations of the Inception network.
Further insights and an independent evaluation of the FID score can be found in Are GANs Created Equal? A Large-Scale Study.
The weights and the model are exactly the same as in the official Tensorflow implementation, and were tested to give very similar results (e.g. .08 absolute error and 0.0009 relative error on LSUN, using ProGAN generated images). However, due to differences in the image interpolation implementation and library backends, FID results still differ slightly from the original implementation. So if you report FID scores in your paper, and you want them to be exactly comparable to FID scores reported in other papers, you should consider using the official Tensorflow implementation.
Installation
Install from pip:
pip install pytorch-fid
Requirements:
- python3
- pytorch
- torchvision
- pillow
- numpy
- scipy
Usage
To compute the FID score between two datasets, where images of each dataset are contained in an individual folder:
python -m pytorch_fid path/to/dataset1 path/to/dataset2
To run the evaluation on GPU, use the flag --device cuda:N, where N is the index of the GPU to use.