AGENT SKILL

pytorch-fid

Use pytorch-fid to compute Frechet Inception Distance for image directories or saved activation statistics, precompute .npz stats, validate inputs, and troubleshoot PyTorch Inception FID workflows.

License 许可
Apache-2.0
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
pytorch-fid
license
Apache 2.0
metadata
{ "disco-role": "operating" }
description
Use pytorch-fid to compute Frechet Inception Distance for image directories or saved activation statistics, precompute .npz stats, validate inputs, and troubleshoot PyTorch Inception FID workflows.
disable-model-invocation
true

02 资源文件 10

03 SKILL.md 正文

pytorch-fid

Use this repo skill when a task involves pytorch-fid, the pytorch_fid Python package, Frechet Inception Distance (FID), image dataset quality comparison, GAN or diffusion sample evaluation, Inception feature dimensions, or .npz activation-statistics files produced by this package.

First checks

  1. Confirm the public package and import name:
    • package/distribution: pytorch-fid
    • import package: pytorch_fid
    • console script: pytorch-fid
    • module CLI: python -m pytorch_fid
  2. Run the safe environment probe before giving install or runtime advice:
    python scripts/check_pytorch_fid_env.py
    
    Add --json when a machine-readable report is needed.
  3. If the task depends on the source snapshot, read references/repo-provenance.md.
  4. If the task is about router selection or when this skill should load, read references/repo-routing-metadata.json.
  5. For first-run or failure diagnosis, start with references/troubleshooting.md.

Minimal import smoke:

from pytorch_fid.fid_score import calculate_fid_given_paths
from pytorch_fid.inception import InceptionV3

The import smoke must not construct InceptionV3 unless a model download/cache check is explicitly allowed. The bundled scripts avoid model construction.

When to read this skill

Read this skill when the user asks to:

  • compute FID between two image directories;
  • precompute one dataset's Inception statistics for later comparisons;
  • compare an image directory against a saved .npz statistics file;
  • call the pytorch_fid.fid_score APIs from Python;
  • select --dims values 64, 192, 768, or 2048;
  • choose CPU, CUDA device strings, batch size, or DataLoader worker count;
  • validate whether directories and .npz files are compatible before running;
  • troubleshoot unsupported image files, empty directories, CUDA/OOM, missing weights, shape mismatches, singular covariances, or non-comparable scores.

Avoid this skill when the task is only generic image preprocessing, generic PyTorch model training, TensorFlow FID code, CLIP-based image metrics, or repo maintenance unrelated to using the packaged FID workflows.

Route map

Use the bundled references instead of returning long inline explanations:

Use bundled scripts for safe checks:

Core operating workflow

  1. Identify the two comparison inputs. Each input can be an image directory or a .npz file containing saved activation statistics. If both are directories, the package computes statistics for both in the same run.
  2. Validate inputs before constructing a model:
    python scripts/validate_fid_inputs.py INPUT_A INPUT_B --expected-dims 2048
    
    Omit --expected-dims when the intended feature dimension is not known yet.
  3. Choose the feature dimension. Default is 2048; lower dimensions (64, 192, 768) are faster but not directly comparable to 2048 scores.
  4. Choose device and batch parameters. Start with CPU or --device cuda:0 only after verifying CUDA availability; reduce --batch-size for memory errors.
  5. Run via CLI for ordinary comparisons:
    python -m pytorch_fid PATH_A PATH_B --dims 2048 --batch-size 50
    
  6. Precompute reusable reference statistics when one dataset is reused often:
    python -m pytorch_fid --save-stats DATASET_DIR reference_stats.npz
    
  7. Compare generated images against saved stats:
    python -m pytorch_fid GENERATED_DIR reference_stats.npz --dims 2048
    
  8. For Python integration, prefer the public functions in references/api-reference.md and keep path, dimension, and device checks explicit in the calling code.

Important constraints

  • Supported image extensions are bmp, jpg, jpeg, pgm, png, ppm, tif, tiff, and webp; use lowercase suffixes for reliable source matching across platforms.
  • Saved stats must contain finite mu and sigma arrays; sigma must be a square covariance matrix whose side length matches mu length.
  • The first real FID run may download Inception weights unless they are already available in the PyTorch cache. Do not treat a network failure as an input validation failure.
  • Scores are comparable only when the same package/version, preprocessing, Inception weights, feature dimension, and dataset conventions are used.
  • The README warns that scores are not exactly comparable with the official TensorFlow FID implementation.
  • CPU is a valid backend for correctness checks; CUDA is optional acceleration.
  • With torch builds that are not compatible with NumPy 2, use a NumPy 1.x runtime such as numpy<2 to avoid ABI warnings or import failures.

Troubleshooting entry points

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-triton-opt

Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-solve

END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-skill

PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-pattern-fusion

Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-orchestrate

Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-feedback

Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).

★ 351