Registry / ai-ml / pytorch-fid

pytorch-fid

JSON →
library0.3.0pypypi✓ verified 85d ago

A PyTorch implementation of the Frechet Inception Distance (FID) for evaluating generative models. Version 0.3.0 is the latest stable release. The package is mature with infrequent releases.

pip install pytorch-fid
INSTALL
IMPORT
SIG · PYTORCH-FID
P
pytorch-fid
ai-mlpythonv0.3.0
Install
73.4s avg
Import
Disk
5018MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 82.2s
py 3.11
✕ build_error
✓ 81.9s
py 3.12
✕ build_error
✓ 65.4s
py 3.13
✕ build_error
✓ 63.9s
py 3.9
✕ build_error
✕ timeout
5018MB installed
● package 5018MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

calculate_fid_given_paths
from pytorch_fid import fid_score
from pytorch_fid import fid_score; fid_score.calculate_fid_given_paths(paths, batch_size, device, dims, num_workers)

Example of calculating FID between two directories of images.

import torch from pytorch_fid import fid_score paths = ['path/to/real/images', 'path/to/fake/images'] # Use GPU if available device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') # Calculate FID fid_value = fid_score.calculate_fid_given_paths(paths, batch_size=50, device=device, dims=2048, num_workers=8) print('FID:', fid_value)
pytorch-fid --version
Debug
Known issues
breakingIn version 0.4.0 (unreleased), the API will change; the function `calculate_fid_given_paths` will be renamed to `compute_fid` and its argument signature will change. Check the GitHub master branch for future compatibility.
fix
Use the current API (0.3.0) or monitor the repo for updates.
affects: >=0.4.0 (future)
gotchaThe Inception v3 model used by pytorch-fid is not the standard torchvision one; it uses pre-trained weights from the TensorFlow implementation. If you use your own Inception model, FID scores will be inconsistent.
fix
Always use the bundled weights (loaded automatically) from the pytorch_fid/inception.py file.
affects: all
deprecatedThe `dims` parameter accepts values 64, 192, 768, 2048. Using dims other than 2048 produces incomplete FID (not the true FID). This is a leftover from older experiments.
fix
Always use dims=2048 for standard FID.
affects: all
gotchaImage directories must contain only valid image files (jpg, png). Non-image files or corrupted images cause silent failures or crashes.
fix
Sanitize directories to contain only supported image formats.
affects: all
Upgrade
Version history
0.3.0latest on PyPI · released Jan 5, 2023
Audit
Dependencies
torchrequiredCore dependency for PyTorch operations
torchvisionrequiredProvides Inception v3 model and image transforms
numpyrequiredUsed for matrix operations and statistics
scipyrequiredUsed for FID computation (matrix square root and trace)
Agent activity
14 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources