Tensorflow implementation of the "Fréchet Inception Distance" (FID) between two image distributions, along with a numpy interface. The FID can be used to evaluate generative models by calculating the FID between real and fake data distributions (lower is better).
- tensorflow==1.14or (- tensorflow==1.15and- tensorflow-gan==1.0.0.dev0) or (- tensorflow>=2and- tensorflow-gan>=2.0.0)
- Fast, easy-to-use and memory-efficient
- No prior knowledge about Tensorflow is necessary if your are using CPUs or GPUs
- Makes use of TF-GAN
- Downloads InceptionV1 automatically
- Compatible with both Python 2 and Python 3
- If you are working with GPUs, use fid.py; if you are working with TPUs, usefid_tpu.pyand pass a Tensorflow Session and a TPUStrategy as additional arguments.
- Call get_fid(images1, images2), whereimages1,images2are numpy arrays with values ranging from 0 to 255 and shape in the form[N, 3, HEIGHT, WIDTH]whereN,HEIGHTandWIDTHcan be arbitrary.dtypeof the images is recommended to benp.uint8to save CPU memory.
- A smaller BATCH_SIZEreduces GPU/TPU memory usage, but at the cost of a slight slowdown.
- If you want to compute a general "Fréchet Classifier Distance" with activations (e.g., outputs of the last pooling layer) act1andact2from another classifier, callactivations2distance(act1, act2).act1andact2can be numpy arrays of a same arbitrary shape[N, d].
- The Fréchet Inception Distance was proposed in the paper GANs Trained by a Two Time-Scale Update Rule Converge to a Local Nash Equilibrium
- Code for the Inception Score