torch-fidelity implements Inception Score, FID, KID, PPL, and related metrics for generative models with shared features and caching in PyTorch.
Overview
torch-fidelity provides implementations of common metrics used to evaluate generative models, especially image generators, within PyTorch workflows. Metrics include Inception Score, Fréchet Inception Distance, Kernel Inception Distance, perceptual path length, and precision-related measures covered in bundled documentation.
The design stresses numerical agreement with reference implementations up to floating-point precision, so results can be reported in research papers without relying on scattered reference codebases. Feature extraction is shared across metrics to avoid redundant computation, and caching reduces repeated work when evaluating repeatedly during training.
Modular design allows registering custom feature extractors so evaluation can extend beyond 2D images to other modalities such as video, audio, or volumes when a suitable representation model exists. A command-line fidelity tool supports quick runs on datasets, image folders, or ONNX generators, while the Python API integrates into training loops with metric dictionaries suitable for loggers.
Documentation points to training examples that call the API each epoch. Installation follows standard Python packaging. Teams training GANs or other generative models who need fast, consistent metric batches inside PyTorch benefit from consolidating evaluation in one package.
Key features
- FID, KID, and Inception Score
- Shared feature extraction
- Metric result caching
- Python API for training loops
- Command-line fidelity tool
- Custom feature extractors
- ONNX generator evaluation
- Precision-oriented numerics
Use cases
- GAN training monitoring
- Paper metric reporting
- Per-epoch model evaluation
- CIFAR-scale benchmark runs
- Custom modality metrics