来源于文章题目:GANs Trained by a Two Time-Scale Update Rule Converge to a Local Nash Equilibrium
地址:https://arxiv.org/abs/1706.08500
代码地址:GitHub - bioinf-jku/TTUR: Two time-scale update rule for training GANs
介绍:
Frechet Inception 距离得分(Frechet Inception Distance score,FID)是计算真实图像和生成图像的特征向量之间距离的一种度量。
FID 从原始图像的计算机视觉特征的统计方面的相似度来衡量两组图像的相似度,这种视觉特征是使用 Inception v3 图像分类模型计算的得到的。分数越低代表两组图像越相似,或者说二者的统计量越相似,FID 在最佳情况下的得分为 0.0,表示两组图像相同。(其中文件夹1与文件夹2的图像数量可以不一致)
https://github.com/mseitzer/pytorch-fidhttps://github.com/mseitzer/pytorch-fid
首先安装:
pip install pytorch-fid==0.1.1
使用方式:
python -m pytorch_fid path/to/dataset1 path/to/dataset2
用 --gpu N表示使用第N个GPU
例如命令:
python -m pytorch_fid groundtruth input --gpu 0
如果要使用CPU,直接把--gpu 0删除就可以了,直接
python -m pytorch_fid groundtruth input
示例:
例如在该项目下使用该命令:
python -m pytorch_fid datasets/colorization/sidd/val/groundtruth datasets/colorization/sidd/val/input --gpu 0
最终得到得分:
有一些网友遇到的bug:
1、AttributeError: module 'os' has no attribute 'sched_getaffinity
pip install pytorch-fid==0.2.1
这是因为你安装的版本是:0.2.1,然后你现在用的是windows而不是linux,如果你想要在windows上运行,只需要将--number_workers设置为0就可以了:
--device cpu/cuda
python -m pytorch_fid c/input_images/ c/output_images/ --num-workers 0 --device cpu
2024-5月更新
目前最新版的FID(0.3.0)计算,与原始的计算方式不同:
pip install pytorch-fid
使用方法:
python -m pytorch_fid path/to/dataset1 path/to/dataset2
使用GPU计算:
python -m pytorch_fid path/to/dataset1 path/to/dataset2 --device cuda:0
其中--device cuda:N
, where N
is the index of the GPU to use.
GitHub - mseitzer/pytorch-fid: Compute FID scores with PyTorch.