{"id":21834,"library":"pytorch-fid","title":"PyTorch FID","description":"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.","status":"active","version":"0.3.0","language":"python","source_language":"en","source_url":"https://github.com/mseitzer/pytorch-fid","tags":["fid","frechet-inception-distance","generative-models","gan-evaluation","pytorch"],"install":[{"cmd":"pip install pytorch-fid","lang":"bash","label":"Standard install"}],"dependencies":[{"reason":"Core dependency for PyTorch operations","package":"torch","optional":false},{"reason":"Provides Inception v3 model and image transforms","package":"torchvision","optional":false},{"reason":"Used for matrix operations and statistics","package":"numpy","optional":false},{"reason":"Used for FID computation (matrix square root and trace)","package":"scipy","optional":false}],"imports":[{"note":"The function is not exported directly; you must access it via the fid_score module.","wrong":"from pytorch_fid.fid_score import calculate_fid_given_paths","symbol":"calculate_fid_given_paths","correct":"from pytorch_fid import fid_score; fid_score.calculate_fid_given_paths(paths, batch_size, device, dims, num_workers)"}],"quickstart":{"code":"import torch\nfrom pytorch_fid import fid_score\n\npaths = ['path/to/real/images', 'path/to/fake/images']\n\n# Use GPU if available\ndevice = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n\n# Calculate FID\nfid_value = fid_score.calculate_fid_given_paths(paths, batch_size=50, device=device, dims=2048, num_workers=8)\nprint('FID:', fid_value)","lang":"python","description":"Example of calculating FID between two directories of images."},"warnings":[{"fix":"Use the current API (0.3.0) or monitor the repo for updates.","message":"In 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.","severity":"breaking","affected_versions":">=0.4.0 (future)"},{"fix":"Always use the bundled weights (loaded automatically) from the pytorch_fid/inception.py file.","message":"The 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.","severity":"gotcha","affected_versions":"all"},{"fix":"Always use dims=2048 for standard FID.","message":"The `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.","severity":"deprecated","affected_versions":"all"},{"fix":"Sanitize directories to contain only supported image formats.","message":"Image directories must contain only valid image files (jpg, png). Non-image files or corrupted images cause silent failures or crashes.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `pip install pytorch-fid` and verify with `pip list | grep pytorch-fid`.","cause":"Package not installed or misspelled.","error":"ModuleNotFoundError: No module named 'pytorch_fid'"},{"fix":"Import via `from pytorch_fid import fid_score` then call `fid_score.calculate_fid_given_paths(...)`.","cause":"Direct import of the function from the package root is incorrect.","error":"AttributeError: module 'pytorch_fid' has no attribute 'calculate_fid_given_paths'"},{"fix":"Reduce batch_size parameter (e.g., to 16 or 8) or use CPU with device='cpu'.","cause":"Batch size too large for GPU memory.","error":"RuntimeError: CUDA out of memory. Tried to allocate ... MiB (GPU 0; ... MiB total capacity)"},{"fix":"Check that both paths exist and are directories containing images.","cause":"Incorrect path to image directory.","error":"ValueError: Input path ... does not exist or is not a directory"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}