CIFAR-10 Frechet Inception Distance (FID) Calculation This repository contains a Python script to calculate the Frechet Inception Distance (FID) between two sets of images using the InceptionV3 model. The FID metric is commonly used to evaluate the quality of images generated by generative models by comparing them to real images. This script demonstrates how to load CIFAR-10 dataset images, preprocess them, and compute the FID score.
Key Features: CIFAR-10 Data Loading: Includes a function to load CIFAR-10 data from binary files. Image Scaling: Resizes images to match the input size required by the InceptionV3 model. FID Calculation: Computes the FID score by comparing the statistics (mean and covariance) of activations from the InceptionV3 model for two image datasets. Model Initialization: Initializes the InceptionV3 model with pre-trained weights that must be downloaded separately. Example Usage: The script calculates FID using the same set of images to demonstrate the process.
Files and Directories: CIFAR-10 Dataset: The script expects the CIFAR-10 dataset in binary format. InceptionV3 Weights: The script requires a local file path to the pre-trained weights of the InceptionV3 model.
How to Use: Download CIFAR-10 Data: Ensure you have the CIFAR-10 dataset downloaded and extracted in the specified path. Download InceptionV3 Weights: Manually download the InceptionV3 model weights (inception_v3_weights_tf_dim_ordering_tf_kernels_notop.h5) and specify the path in the script. Run the Script: Execute the script to load images, preprocess them, and calculate the FID score.
Example:
This score indicates the FID between the same set of images, which should ideally be zero.
Dependencies: numpy scipy keras (for the InceptionV3 model) skimage (for image resizing) This project serves as a foundational example of using FID to evaluate the similarity between image datasets in terms of feature distributions.