This is a PyTorch implementation of Fréchet Inception Distance (FID), spatial Fréchet Inception Distance (sFID), Inception Score (IS), Precision & Recall evalution for image generation task.
A widely acknowledged TensorFlow implementation is guided-diffusion/evaluations
-
Download InceptionV3 wights provided by pytorch-fid
-
Prepare reference statistics:
- for ImageNet, you can download reference npz file (
ref_npz) from guided-diffusion/evaluations - for customized datasets, you need to prepare a sets of reference images (
ref_imageset) - (optional) you can compress your
ref_imagesetintoref_npzby
python metrics.py --weights path/to/inception_weights \ --src-path path/to/ref_imageset --save-src-npz-path path/to/ref_npz - for ImageNet, you can download reference npz file (
-
Generate source images with your model (
src_imageset), e.g. 50000 images typically. Then calculate FID, sFID, IS, precision & recall:
python metrics.py --weights path/to/inception_weights \
--src-path path/to/src_imageset --ref-path path/to/ref_npz
# or
python metrics.py --weights path/to/inception_weights \
--src-path path/to/src_imageset --ref-path path/to/ref_imageset
This project is based on following projects:
This implementation is licensed under the Apache License 2.0.