[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"tool-toshas--torch-fidelity":3,"similar-toshas--torch-fidelity":119},{"id":4,"github_repo":5,"name":6,"description_en":7,"description_zh":8,"ai_summary_zh":9,"readme_en":10,"readme_zh":11,"quickstart_zh":12,"use_case_zh":13,"hero_image_url":14,"owner_login":15,"owner_name":16,"owner_avatar_url":17,"owner_bio":18,"owner_company":19,"owner_location":19,"owner_email":19,"owner_twitter":20,"owner_website":21,"owner_url":22,"languages":23,"stars":36,"forks":37,"last_commit_at":38,"license":39,"difficulty_score":40,"env_os":41,"env_gpu":42,"env_ram":41,"env_deps":43,"category_tags":52,"github_topics":56,"view_count":40,"oss_zip_url":19,"oss_zip_packed_at":19,"status":69,"created_at":70,"updated_at":71,"faqs":72,"releases":103},956,"toshas\u002Ftorch-fidelity","torch-fidelity","High-fidelity performance metrics for generative models in PyTorch","torch-fidelity 是一款专为 PyTorch 设计的生成模型评估工具，帮助开发者和研究者快速、准确地衡量图像生成模型的质量。它集成了业界主流的评估指标，包括 Inception Score（ISC）、Fréchet Inception Distance（FID）、Kernel Inception Distance（KID）、Precision\u002FRecall（PRC）以及 Perceptual Path Length（PPL），覆盖从图像清晰度到多样性的全方位评估需求。\n\n这款工具主要解决了生成模型评估中的三大痛点：精度不一致、计算效率低、扩展性差。与许多重新实现的版本不同，torch-fidelity 的数值结果与官方参考实现达到机器精度级别的一致，这意味着你可以直接将其用于学术论文的指标报告，无需再依赖分散且缓慢的原始代码。同时，通过特征共享和智能缓存机制，它能显著减少重复计算，支持在训练循环中实时评估，比如每个 epoch 结束后快速获取模型表现。此外，模块化的架构设计让你可以轻松扩展至视频、音频、3D 体数据等其他模态，只需注册自定义的特征提取器即可。\n\ntorch-","torch-fidelity 是一款专为 PyTorch 设计的生成模型评估工具，帮助开发者和研究者快速、准确地衡量图像生成模型的质量。它集成了业界主流的评估指标，包括 Inception Score（ISC）、Fréchet Inception Distance（FID）、Kernel Inception Distance（KID）、Precision\u002FRecall（PRC）以及 Perceptual Path Length（PPL），覆盖从图像清晰度到多样性的全方位评估需求。\n\n这款工具主要解决了生成模型评估中的三大痛点：精度不一致、计算效率低、扩展性差。与许多重新实现的版本不同，torch-fidelity 的数值结果与官方参考实现达到机器精度级别的一致，这意味着你可以直接将其用于学术论文的指标报告，无需再依赖分散且缓慢的原始代码。同时，通过特征共享和智能缓存机制，它能显著减少重复计算，支持在训练循环中实时评估，比如每个 epoch 结束后快速获取模型表现。此外，模块化的架构设计让你可以轻松扩展至视频、音频、3D 体数据等其他模态，只需注册自定义的特征提取器即可。\n\ntorch-fidelity 特别适合从事生成式 AI 研究的科研人员、开发 GAN 或扩散模型的算法工程师，以及需要标准化评估流程的机器学习团队。无论是快速验证实验效果，还是进行严谨的模型对比，它都能提供可靠的支持。安装简单，一行 pip 命令即可上手，同时支持命令行和 Python API 两种调用方式，灵活适应不同的工作场景。","![High-fidelity performance metrics for generative models in PyTorch](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftoshas_torch-fidelity_readme_b05165068a18.png)\n\n[![Documentation Status](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftoshas_torch-fidelity_readme_13d664e1afd7.png)](https:\u002F\u002Ftorch-fidelity.readthedocs.io\u002Fen\u002Flatest\u002F?badge=latest)\n[![TestStatus](https:\u002F\u002Fcircleci.com\u002Fgh\u002Ftoshas\u002Ftorch-fidelity.svg?style=shield)](https:\u002F\u002Fcircleci.com\u002Fgh\u002Ftoshas\u002Ftorch-fidelity)\n[![PyPiVersion](https:\u002F\u002Fbadge.fury.io\u002Fpy\u002Ftorch-fidelity.svg)](https:\u002F\u002Fpypi.org\u002Fproject\u002Ftorch-fidelity\u002F)\n[![PyPiDownloads](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftoshas_torch-fidelity_readme_7ccfe6d071e4.png)](https:\u002F\u002Fpepy.tech\u002Fproject\u002Ftorch-fidelity)\n[![Twitter Follow](https:\u002F\u002Fimg.shields.io\u002Ftwitter\u002Ffollow\u002FAntonObukhov1?style=social&label=Subscribe!)](https:\u002F\u002Ftwitter.com\u002Fantonobukhov1)\n\nThis repository provides **precise**, **efficient**, and **extensible** implementations of the popular metrics for \ngenerative model evaluation, including:\n- Inception Score ([ISC](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1606.03498.pdf))\n- Fréchet Inception Distance ([FID](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1706.08500.pdf))\n- Kernel Inception Distance ([KID](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1801.01401.pdf))\n- Precision and Recall ([PRC](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1904.06991.pdf))\n- Perceptual Path Length ([PPL](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1812.04948.pdf))\n\n**Numerical Precision**: Unlike many other reimplementations, the values produced by torch-fidelity match reference \nimplementations up to floating point's machine precision. This allows using torch-fidelity for reporting metrics in papers instead of \nscattered and slow reference implementations. [Read more about numerical precision](https:\u002F\u002Ftorch-fidelity.readthedocs.io\u002Fen\u002Flatest\u002Fprecision.html) \n\n**Efficiency**: Feature sharing between different metrics saves recomputation time, and an additional caching \nlevel avoids recomputing features and statistics whenever possible. High efficiency allows using torch-fidelity in the \ntraining loop, for example at the end of every epoch. [Read more about efficiency](https:\u002F\u002Ftorch-fidelity.readthedocs.io\u002Fen\u002Flatest\u002Fmiscellaneous.html)\n\n**Extensibility**: Going beyond 2D image generation is easy due to high modularity and abstraction of the metrics from\ninput data, models, and feature extractors. Register a custom feature extractor to evaluate any modality — video, audio,\n3D volumes, or anything else with a suitable learned representation. [Read more about extensibility](https:\u002F\u002Ftorch-fidelity.readthedocs.io\u002Fen\u002Flatest\u002Fextensibility.html)\n\n**TLDR; fast and reliable generative model evaluation in PyTorch**\n\n## Installation\n\n```shell script\npip install torch-fidelity\n```\n\nSee also: [Installing the latest GitHub code](https:\u002F\u002Ftorch-fidelity.readthedocs.io\u002Fen\u002Flatest\u002Finstallation.html#nightly-version) \n\n## Usage Examples with Command Line\n\nBelow are three examples of using torch-fidelity to evaluate metrics from the command line. See more examples in the \ndocumentation.\n\n### Simple \n\nInception Score of CIFAR-10 training split:\n```shell script\n> fidelity --gpu 0 --isc --input1 cifar10-train\n\ninception_score_mean: 11.23678\ninception_score_std: 0.09514061\n```\n\n### Medium \n\nInception Score of a directory of images stored in `~\u002Fimages\u002F`:\n```shell script\n> fidelity --gpu 0 --isc --input1 ~\u002Fimages\u002F\n```\n\n### Pro\n\nEfficient computation of ISC and PPL for `input1`, and FID, KID, PRC between a generative model stored in `~\u002Fgenerator.onnx` and CIFAR-10 training split:\n```shell script\n> fidelity \\\n  --gpu 0 \\\n  --isc \\\n  --fid \\\n  --kid \\\n  --ppl \\\n  --prc \\\n  --input1 ~\u002Fgenerator.onnx \\ \n  --input1-model-z-type normal \\\n  --input1-model-z-size 128 \\\n  --input1-model-num-samples 50000 \\ \n  --input2 cifar10-train \n```\n\nSee also: [Other usage examples](https:\u002F\u002Ftorch-fidelity.readthedocs.io\u002Fen\u002Flatest\u002Fusage_cmd.html)\n\n## Quick Start with Python API\n\nWhen it comes to tracking the performance of generative models as they train, evaluating metrics after every epoch \nbecomes prohibitively expensive due to long computation times. \n`torch_fidelity` tackles this problem by making full use \nof caching to avoid recomputing common features and per-metric statistics whenever possible. \nComputing all metrics for 50000 32x32 generated images and `cifar10-train` takes a fraction of the time compared to\nusing original codebases, thanks to feature sharing and caching.\n\nIn the following example, assume unconditional image generation setting with CIFAR-10, and the generative model \n`generator`, which takes a 128-dimensional standard normal noise vector.\n\nFirst, import the module:\n\n```python\nimport torch_fidelity\n```\n\nAdd the following lines at the end of epoch evaluation:\n```python\nwrapped_generator = torch_fidelity.GenerativeModelModuleWrapper(generator, 128, 'normal', 0)\n\nmetrics_dict = torch_fidelity.calculate_metrics(\n    input1=wrapped_generator, \n    input2='cifar10-train', \n    cuda=True, \n    isc=True, \n    fid=True, \n    kid=True, \n    prc=True, \n    verbose=False,\n)\n```\n\nThe resulting dictionary with computed metrics can logged directly to tensorboard, wandb, or console: \n\n```python\nprint(metrics_dict)\n```\n\nOutput:\n\n```python\n{\n    'inception_score_mean': 11.23678, \n    'inception_score_std': 0.09514061, \n    'frechet_inception_distance': 18.12198,\n    'kernel_inception_distance_mean': 0.01369556, \n    'kernel_inception_distance_std': 0.001310059\n    'precision': 0.51369556, \n    'recall': 0.501310059\n}\n```\n\nSee also: [Full API reference](https:\u002F\u002Ftorch-fidelity.readthedocs.io\u002Fen\u002Flatest\u002Fapi.html)\n\n### Example of Integration with the Training Loop\n\nRefer to [sngan_cifar10.py](examples\u002Fsngan_cifar10.py) for a complete training example.\n\nEvolution of fixed generator latents in the example:\n\n![Evolution of fixed generator latents](doc\u002Fimg\u002Fsngan-cifar10.gif)\n\nA generator checkpoint resulting from training the example can be downloaded \n[here](https:\u002F\u002Fgithub.com\u002Ftoshas\u002Ftorch-fidelity\u002Freleases\u002Fdownload\u002Fv0.2.0\u002Fexample-sngan-cifar10-generator.pth). \n\n## Troubleshooting\n\n###   WARNING: The script fidelity is installed in '\u003CSOMEPATH>' which is not on PATH.\n\nSuggests that the standalone `fidelity` tool will not be available unless the above path is added to the PATH \nenvironment variable. If modifying it is undesirable, the tool can still be called by its full path: `\u003CSOMEPATH>\u002Ffidelity`.\n\n## Citation\n\nCitation is recommended to reinforce the evaluation protocol in works relying on torch-fidelity. \nTo ensure reproducibility when citing this repository, use the following BibTeX:\n\n```\n@misc{obukhov2020torchfidelity,\n  author={Anton Obukhov and Maximilian Seitzer and Po-Wei Wu and Semen Zhydenko and Jonathan Kyl and Elvis Yu-Jing Lin},\n  year=2020,\n  title={High-fidelity performance metrics for generative models in PyTorch},\n  url={https:\u002F\u002Fgithub.com\u002Ftoshas\u002Ftorch-fidelity},\n  publisher={Zenodo},\n  version={v0.4.0},\n  doi={10.5281\u002Fzenodo.3786539},\n  note={Version: 0.4.0, DOI: 10.5281\u002Fzenodo.3786539}\n}\n```\n","![PyTorch 中生成模型的高保真性能指标](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftoshas_torch-fidelity_readme_b05165068a18.png)\n\n[![文档状态](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftoshas_torch-fidelity_readme_13d664e1afd7.png)](https:\u002F\u002Ftorch-fidelity.readthedocs.io\u002Fen\u002Flatest\u002F?badge=latest)\n[![测试状态](https:\u002F\u002Fcircleci.com\u002Fgh\u002Ftoshas\u002Ftorch-fidelity.svg?style=shield)](https:\u002F\u002Fcircleci.com\u002Fgh\u002Ftoshas\u002Ftorch-fidelity)\n[![PyPi版本](https:\u002F\u002Fbadge.fury.io\u002Fpy\u002Ftorch-fidelity.svg)](https:\u002F\u002Fpypi.org\u002Fproject\u002Ftorch-fidelity\u002F)\n[![PyPi下载量](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftoshas_torch-fidelity_readme_7ccfe6d071e4.png)](https:\u002F\u002Fpepy.tech\u002Fproject\u002Ftorch-fidelity)\n[![Twitter关注](https:\u002F\u002Fimg.shields.io\u002Ftwitter\u002Ffollow\u002FAntonObukhov1?style=social&label=订阅！)](https:\u002F\u002Ftwitter.com\u002Fantonobukhov1)\n\n该存储库提供了用于生成模型评估的流行指标的**精确**、**高效**和**可扩展**实现，包括：\n- Inception Score（[ISC](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1606.03498.pdf)，初始得分）\n- Fréchet Inception Distance（[FID](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1706.08500.pdf)，Fréchet 初始距离）\n- Kernel Inception Distance（[KID](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1801.01401.pdf)，核初始距离）\n- Precision and Recall（[PRC](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1904.06991.pdf)，精度与召回率）\n- Perceptual Path Length（[PPL](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1812.04948.pdf)，感知路径长度）\n\n**数值精度**：与其他许多重新实现不同，torch-fidelity 生成的值与参考实现匹配到浮点数的机器精度。这使得可以使用 torch-fidelity 在论文中报告指标，而不是分散且缓慢的参考实现。[了解更多关于数值精度的信息](https:\u002F\u002Ftorch-fidelity.readthedocs.io\u002Fen\u002Flatest\u002Fprecision.html) \n\n**效率**：不同指标之间的特征共享节省了重复计算时间，额外的缓存层尽可能避免重新计算特征和统计信息。高效率使得可以在训练循环中使用 torch-fidelity，例如在每个 epoch 结束时。[了解更多关于效率的信息](https:\u002F\u002Ftorch-fidelity.readthedocs.io\u002Fen\u002Flatest\u002Fmiscellaneous.html)\n\n**可扩展性**：由于指标的高度模块化和抽象性，超越 2D 图像生成变得容易。注册一个自定义特征提取器即可评估任何模态——视频、音频、3D 体积或任何其他具有适当学习表示的内容。[了解更多关于可扩展性的信息](https:\u002F\u002Ftorch-fidelity.readthedocs.io\u002Fen\u002Flatest\u002Fextensibility.html)\n\n**简而言之；快速可靠的 PyTorch 生成模型评估**\n\n## 安装\n\n```shell script\npip install torch-fidelity\n```\n\n另请参阅：[安装最新的 GitHub 代码](https:\u002F\u002Ftorch-fidelity.readthedocs.io\u002Fen\u002Flatest\u002Finstallation.html#nightly-version) \n\n## 命令行用法示例\n\n以下是使用 torch-fidelity 从命令行评估指标的三个示例。更多示例请参见文档。\n\n### 简单示例\n\nCIFAR-10 训练集的 Inception Score：\n```shell script\n> fidelity --gpu 0 --isc --input1 cifar10-train\n\ninception_score_mean: 11.23678\ninception_score_std: 0.09514061\n```\n\n### 中等示例\n\n存储在 `~\u002Fimages\u002F` 目录中的图像的 Inception Score：\n```shell script\n> fidelity --gpu 0 --isc --input1 ~\u002Fimages\u002F\n```\n\n### 高级示例\n\n为 `input1` 高效计算 ISC 和 PPL，并为存储在 `~\u002Fgenerator.onnx` 的生成模型与 CIFAR-10 训练集之间计算 FID、KID 和 PRC：\n```shell script\n> fidelity \\\n  --gpu 0 \\\n  --isc \\\n  --fid \\\n  --kid \\\n  --ppl \\\n  --prc \\\n  --input1 ~\u002Fgenerator.onnx \\ \n  --input1-model-z-type normal \\\n  --input1-model-z-size 128 \\\n  --input1-model-num-samples 50000 \\ \n  --input2 cifar10-train \n```\n\n另请参阅：[其他用法示例](https:\u002F\u002Ftorch-fidelity.readthedocs.io\u002Fen\u002Flatest\u002Fusage_cmd.html)\n\n## Python API 快速入门\n\n当涉及到跟踪生成模型在训练过程中的性能时，由于计算时间过长，在每个 epoch 后评估指标变得非常昂贵。\n`torch_fidelity` 通过充分利用缓存来解决此问题，尽可能避免重新计算常见特征和每种指标的统计数据。\n得益于特征共享和缓存，计算 50000 张 32x32 生成图像和 `cifar10-train` 的所有指标所需的时间只是使用原始代码库的一小部分。\n\n在以下示例中，假设是无条件图像生成设置，使用 CIFAR-10 数据集和生成模型 `generator`，它接受一个 128 维的标准正态噪声向量。\n\n首先，导入模块：\n\n```python\nimport torch_fidelity\n```\n\n在 epoch 评估结束时添加以下代码：\n```python\nwrapped_generator = torch_fidelity.GenerativeModelModuleWrapper(generator, 128, 'normal', 0)\n\nmetrics_dict = torch_fidelity.calculate_metrics(\n    input1=wrapped_generator, \n    input2='cifar10-train', \n    cuda=True, \n    isc=True, \n    fid=True, \n    kid=True, \n    prc=True, \n    verbose=False,\n)\n```\n\n计算得到的指标字典可以直接记录到 tensorboard、wandb 或控制台：\n\n```python\nprint(metrics_dict)\n```\n\n输出：\n\n```python\n{\n    'inception_score_mean': 11.23678, \n    'inception_score_std': 0.09514061, \n    'frechet_inception_distance': 18.12198,\n    'kernel_inception_distance_mean': 0.01369556, \n    'kernel_inception_distance_std': 0.001310059\n    'precision': 0.51369556, \n    'recall': 0.501310059\n}\n```\n\n另请参阅：[完整 API 参考](https:\u002F\u002Ftorch-fidelity.readthedocs.io\u002Fen\u002Flatest\u002Fapi.html)\n\n### 与训练循环集成的示例\n\n完整的训练示例请参见 [sngan_cifar10.py](examples\u002Fsngan_cifar10.py)。\n\n示例中固定生成器潜在变量的演变：\n\n![固定生成器潜在变量的演变](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftoshas_torch-fidelity_readme_f1d359b2406d.gif)\n\n训练示例后生成的生成器检查点可以从[这里](https:\u002F\u002Fgithub.com\u002Ftoshas\u002Ftorch-fidelity\u002Freleases\u002Fdownload\u002Fv0.2.0\u002Fexample-sngan-cifar10-generator.pth)下载。\n\n## 故障排除\n\n### 警告：脚本 fidelity 安装在 '\u003CSOMEPATH>' 中，该路径不在 PATH 中。\n\n这表明除非将上述路径添加到 PATH 环境变量中，否则独立的 `fidelity` 工具将不可用。如果不想修改 PATH，仍然可以通过其完整路径调用该工具：`\u003CSOMEPATH>\u002Ffidelity`。\n\n## 引用\n\n建议引用以加强依赖于 torch-fidelity 的工作中的评估协议。\n为了确保引用此存储库时的可重复性，请使用以下 BibTeX：\n\n```\n@misc{obukhov2020torchfidelity,\n  author={Anton Obukhov and Maximilian Seitzer and Po-Wei Wu and Semen Zhydenko and Jonathan Kyl and Elvis Yu-Jing Lin},\n  year=2020,\n  title={High-fidelity performance metrics for generative models in PyTorch},\n  url={https:\u002F\u002Fgithub.com\u002Ftoshas\u002Ftorch-fidelity},\n  publisher={Zenodo},\n  version={v0.4.0},\n  doi={10.5281\u002Fzenodo.3786539},\n  note={Version: 0.4.0, DOI: 10.5281\u002Fzenodo.3786539}\n}\n```","# torch-fidelity 快速上手指南\n\ntorch-fidelity 是一个用于评估生成模型性能的 PyTorch 工具，支持多种高精度、高效的指标计算，包括 Inception Score (ISC)、Fréchet Inception Distance (FID)、Kernel Inception Distance (KID)、Precision and Recall (PRC) 和 Perceptual Path Length (PPL)。\n\n以下内容将帮助您快速上手使用 torch-fidelity。\n\n---\n\n## 环境准备\n\n### 系统要求\n- Python 3.7 或更高版本\n- PyTorch 1.8 或更高版本\n- 支持 CUDA 的 GPU（可选，但推荐以加速计算）\n\n### 前置依赖\n在安装 torch-fidelity 之前，请确保已安装以下依赖：\n- PyTorch (`torch`)\n- torchvision (`torchvision`)\n\n如果需要加速安装，可以使用国内镜像源，例如清华源：\n```shell\npip install torch torchvision -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n---\n\n## 安装步骤\n\n通过 pip 安装 torch-fidelity：\n```shell\npip install torch-fidelity\n```\n\n如果您希望安装最新开发版本，可以参考官方文档中的 [GitHub 安装指南](https:\u002F\u002Ftorch-fidelity.readthedocs.io\u002Fen\u002Flatest\u002Finstallation.html#nightly-version)。\n\n---\n\n## 基本使用\n\n### 使用命令行工具\n\n#### 示例 1：计算 CIFAR-10 数据集的 Inception Score\n```shell script\nfidelity --gpu 0 --isc --input1 cifar10-train\n```\n\n输出示例：\n```\ninception_score_mean: 11.23678\ninception_score_std: 0.09514061\n```\n\n#### 示例 2：计算自定义图像目录的 Inception Score\n假设您的图像存储在 `~\u002Fimages\u002F` 目录下：\n```shell script\nfidelity --gpu 0 --isc --input1 ~\u002Fimages\u002F\n```\n\n#### 示例 3：高效计算多个指标\n以下命令同时计算 ISC、FID、KID、PRC 和 PPL 指标，比较生成模型（存储为 ONNX 文件）与 CIFAR-10 数据集：\n```shell script\nfidelity \\\n  --gpu 0 \\\n  --isc \\\n  --fid \\\n  --kid \\\n  --ppl \\\n  --prc \\\n  --input1 ~\u002Fgenerator.onnx \\ \n  --input1-model-z-type normal \\\n  --input1-model-z-size 128 \\\n  --input1-model-num-samples 50000 \\ \n  --input2 cifar10-train \n```\n\n更多命令行用法请参考 [官方文档](https:\u002F\u002Ftorch-fidelity.readthedocs.io\u002Fen\u002Flatest\u002Fusage_cmd.html)。\n\n---\n\n### 使用 Python API\n\n在训练循环中，可以通过 Python API 高效计算生成模型的性能指标。以下是一个简单的示例：\n\n#### 示例代码\n```python\nimport torch_fidelity\n\n# 假设 generator 是您的生成模型，输入为 128 维标准正态分布噪声向量\nwrapped_generator = torch_fidelity.GenerativeModelModuleWrapper(generator, 128, 'normal', 0)\n\n# 计算指标\nmetrics_dict = torch_fidelity.calculate_metrics(\n    input1=wrapped_generator, \n    input2='cifar10-train', \n    cuda=True, \n    isc=True, \n    fid=True, \n    kid=True, \n    prc=True, \n    verbose=False,\n)\n\n# 输出结果\nprint(metrics_dict)\n```\n\n输出示例：\n```python\n{\n    'inception_score_mean': 11.23678, \n    'inception_score_std': 0.09514061, \n    'frechet_inception_distance': 18.12198,\n    'kernel_inception_distance_mean': 0.01369556, \n    'kernel_inception_distance_std': 0.001310059,\n    'precision': 0.51369556, \n    'recall': 0.501310059\n}\n```\n\n更多 API 用法请参考 [完整 API 文档](https:\u002F\u002Ftorch-fidelity.readthedocs.io\u002Fen\u002Flatest\u002Fapi.html)。\n\n---\n\n以上内容涵盖了 torch-fidelity 的基本安装和使用方法。如需更详细的说明或高级功能，请参考 [官方文档](https:\u002F\u002Ftorch-fidelity.readthedocs.io\u002F)。","一位 AI 研究员正在开发一种新的生成对抗网络（GAN），用于生成高质量的医学影像，以辅助医生进行诊断。为了评估模型性能，研究员需要频繁计算多种生成模型指标。\n\n### 没有 torch-fidelity 时\n- 每次实验后，研究员需要手动运行多个独立的脚本分别计算 Inception Score 和 Fréchet Inception Distance，耗时且容易出错。\n- 不同指标工具的实现方式不一致，导致结果缺乏可比性，难以判断模型的真实性能。\n- 在训练过程中实时监控模型表现几乎不可能，因为每次计算都需要重新提取特征，效率低下。\n- 如果想扩展到其他模态数据（如3D医学影像），需要从头开发适配代码，增加了工作量。\n- 使用开源代码时经常遇到数值不稳定问题，影响实验结果的可信度。\n\n### 使用 torch-fidelity 后\n- 研究员可以通过一个命令同时计算多种指标，显著减少了操作复杂度和时间成本。\n- 所有指标的数值精度与参考实现完全一致，确保了实验结果的可靠性和可复现性。\n- 特征共享和缓存机制让研究员能够在每个训练周期结束后快速获取指标反馈，优化模型调参效率。\n- 借助其高度模块化设计，研究员轻松注册了自定义特征提取器，将评估扩展到3D医学影像领域。\n- 数值稳定性得到了保障，研究员可以专注于模型改进，而无需担心工具本身的缺陷。\n\ntorch-fidelity 的高效、精准和灵活特性，帮助研究员大幅提升了生成模型评估的效率和可靠性，为医学影像生成任务提供了坚实的技术支持。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ftoshas_torch-fidelity_f1d359b2.gif","toshas","Anton Obukhov","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Ftoshas_1d5d41f5.jpg","Research Scientist in Computer Vision and Generative AI",null,"AntonObukhov1","obukhov.ai","https:\u002F\u002Fgithub.com\u002Ftoshas",[24,28,32],{"name":25,"color":26,"percentage":27},"Python","#3572A5",97.5,{"name":29,"color":30,"percentage":31},"Shell","#89e051",1.5,{"name":33,"color":34,"percentage":35},"Dockerfile","#384d54",1,1176,87,"2026-04-01T06:01:09","NOASSERTION",3,"未说明","需要 GPU，显存大小未说明，CUDA 版本未说明",{"notes":44,"python":41,"dependencies":45},"工具支持命令行和 Python API 调用，建议使用 pip 安装。首次运行可能需要下载预训练模型文件，具体大小未说明。",[46,47,48,49,50,51],"torch","torchvision","numpy","scipy","onnx","pandas",[53,54,55],"图像","开发框架","其他",[57,58,59,60,61,62,63,64,65,66,67,68],"pytorch","metrics","gan","generative-model","evaluation","inception-score","frechet-inception-distance","kernel-inception-distance","perceptual-path-length","precision","reproducibility","reproducible-research","ready","2026-03-27T02:49:30.150509","2026-04-06T08:45:30.246503",[73,78,83,88,93,98],{"id":74,"question_zh":75,"answer_zh":76,"source_url":77},4220,"为什么计算 FID 时会出现 AssertionError: Imaginary component 错误？","此问题可能与版本有关。建议尝试安装 master 分支的最新代码，可能会修复该问题。安装命令如下：\n```\npip install -e git+https:\u002F\u002Fgithub.com\u002Ftoshas\u002Ftorch-fidelity.git@master#egg=torch-fidelity\n```\n如果问题仍然存在，请等待 0.4.0 版本发布。","https:\u002F\u002Fgithub.com\u002Ftoshas\u002Ftorch-fidelity\u002Fissues\u002F54",{"id":79,"question_zh":80,"answer_zh":81,"source_url":82},4221,"如何解决输入路径导致的 ValueError 错误？","确保输入路径是一个有效的目录，并且包含图像文件。如果使用 Docker 或 Podman，检查是否正确映射了容器内的目录，以及是否有正确的权限。可以通过 `ls` 命令验证路径和文件是否存在。","https:\u002F\u002Fgithub.com\u002Ftoshas\u002Ftorch-fidelity\u002Fissues\u002F65",{"id":84,"question_zh":85,"answer_zh":86,"source_url":87},4222,"如何使用 ResNet34 替代 Inception v3 计算 FID 和 KID？","可以通过注册自定义模型并指定预训练权重路径来实现。调用 `calculate_metrics` 函数时，使用 `feature_extractor_weights_path` 参数加载私有训练的模型检查点。","https:\u002F\u002Fgithub.com\u002Ftoshas\u002Ftorch-fidelity\u002Fissues\u002F60",{"id":89,"question_zh":90,"answer_zh":91,"source_url":92},4223,"为什么 Precision 和 Recall 的结果看起来是颠倒的？","根据定义，可以简单地交换输出中的 Precision 和 Recall 值以获得实际结果。开发者已在 https:\u002F\u002Fgithub.com\u002Ftoshas\u002Ftorch-fidelity\u002Fpull\u002F70 中修复了该问题。","https:\u002F\u002Fgithub.com\u002Ftoshas\u002Ftorch-fidelity\u002Fissues\u002F58",{"id":94,"question_zh":95,"answer_zh":96,"source_url":97},4224,"为什么 Inception 网络的结果会因 batch size 不同而变化？","此问题可能是由于浮点精度不足引起的。尝试将网络和输入数据转换为 float64 类型以解决问题。例如：\n```python\ninception = inception.to(torch.float64)\nimgs = imgs.to(torch.float64)\ninception(imgs)\n```\n开发者已计划在 0.4.0 版本中解决此问题。","https:\u002F\u002Fgithub.com\u002Ftoshas\u002Ftorch-fidelity\u002Fissues\u002F43",{"id":99,"question_zh":100,"answer_zh":101,"source_url":102},4225,"如何解决运行代码时出现的输入路径错误？","确保输入路径格式正确。例如，使用相对路径 `.\u002Fimages\u002F` 而不是 `~\u002Fimages\u002F`。此外，确认路径中包含支持的图像格式（如 png、jpg、jpeg）。","https:\u002F\u002Fgithub.com\u002Ftoshas\u002Ftorch-fidelity\u002Fissues\u002F31",[104,109,114],{"id":105,"version":106,"summary_zh":107,"released_at":108},113362,"v0.4.0","Refer to the [CHANGELOG.md](https:\u002F\u002Fgithub.com\u002Ftoshas\u002Ftorch-fidelity\u002Fblob\u002Fmaster\u002FCHANGELOG.md#040---2026-02-17) for details","2026-02-17T21:15:49",{"id":110,"version":111,"summary_zh":112,"released_at":113},113363,"v0.3.0","Inputs can be models\r\nPerceptual Path Length\r\nDocumentation","2021-06-15T14:28:54",{"id":115,"version":116,"summary_zh":117,"released_at":118},113364,"v0.2.0","Fidelity and determinism tests passing, relative errors updated in README.md.\r\nInception weights reuploaded from https:\u002F\u002Fgithub.com\u002Fmseitzer\u002Fpytorch-fid\u002Freleases in order to assign DOI to this release.","2020-05-05T12:34:08",[120,129,139,147,155,167],{"id":121,"name":122,"github_repo":123,"description_zh":124,"stars":125,"difficulty_score":40,"last_commit_at":126,"category_tags":127,"status":69},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[54,53,128],"Agent",{"id":130,"name":131,"github_repo":132,"description_zh":133,"stars":134,"difficulty_score":135,"last_commit_at":136,"category_tags":137,"status":69},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",140436,2,"2026-04-05T23:32:43",[54,128,138],"语言模型",{"id":140,"name":141,"github_repo":142,"description_zh":143,"stars":144,"difficulty_score":135,"last_commit_at":145,"category_tags":146,"status":69},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[54,53,128],{"id":148,"name":149,"github_repo":150,"description_zh":151,"stars":152,"difficulty_score":135,"last_commit_at":153,"category_tags":154,"status":69},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[54,138],{"id":156,"name":157,"github_repo":158,"description_zh":159,"stars":160,"difficulty_score":135,"last_commit_at":161,"category_tags":162,"status":69},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[53,163,164,165,128,55,138,54,166],"数据工具","视频","插件","音频",{"id":168,"name":169,"github_repo":170,"description_zh":171,"stars":172,"difficulty_score":40,"last_commit_at":173,"category_tags":174,"status":69},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[128,53,54,138,55]]