GaParmar / clean-fid

PyTorch - FID calculation with proper image resizing and quantization steps [CVPR 2022]
https://www.cs.cmu.edu/~clean-fid/
MIT License
971 stars 74 forks source link

Different statistic of FFHQ256 with precompute statistic. #27

Closed guyuchao closed 2 years ago

guyuchao commented 2 years ago

We follow the StyleGAN-ADA to extract FFHQ256 from tfrecord file. However, when I computed the statistic, it results in different statistics from your pre-computed trainval70K. I want to know whether the calculation steps have changed?

guyuchao commented 2 years ago
stat_official=np.load("experiments/pretrained_models/clean_fid/ffhq_clean_trainval70k_256.npz")
print('mu_official',stat_official['mu'].sum()) # 618.9957
print('sigma_official',stat_official['sigma'].sum()) # 12467.119923723967

stat_ours=np.load("experiments/pretrained_models/clean_fid/myffhq_clean_custom_na.npz")
print('mu_our',stat_ours['mu'].sum()) # 622.30695 
print('sigma_our',stat_ours['sigma'].sum()) # 12545.241799384594

The different of statistic results in a very different fid results of our generated images: 13.60(official statistics) vs. 15.31(our statistics).

It seems the problem lies in the dataset or changed statistic calculation pipeline. I provide first ten samples of my ffhq-256 dataset(extracted from tfrecord by StyleGAN-ADA scripts) to help you compare with your ones. https://drive.google.com/file/d/1_8VisJJNiSDs5C9c3msiBgYB1Wl5yNWx/view?usp=sharing

If the dataset is actually the same, you may be change some pipeline in calculating statistics.

GaParmar commented 2 years ago

Hi,

I looked at the images I used for my statistics and the reference 10 images you provided. They are indeed slightly different, which I suspect might be due to how the StyleGAN-ADA preprocess their images.

This is the process I followed for computing my FFHQ statistics: -> Get the 256x256 .tfdir images by getting the file ffhq-r08.tfrecord from the official location. -> Extract just this .tfdir file using the extraction script provided here. -> The above generates a folder of 256x256 images that I use for computing my statistics.

guyuchao commented 2 years ago

I use the same steps as you. Maybe the NumPy or TensorFlow version makes the difference. I need to recompute the fid statistics based on my extracted ffhq256.