Skip to main content
diffeval

diffeval: A Framework for Diffusion Model Evaluation

A fixed prompt and seed suite, scored the same way on every model.

CI Python License

Quickstart · Metrics · Backends · Suites · Extending · Design

diffeval is an evaluation harness for image and video diffusion models, in the same role lm-evaluation-harness has for language models. You name a backend and a suite. The suite fixes the prompts, the seeds, and the resolution. For each seed the backend writes one image per prompt, every metric scores that seed, and the runner aggregates a mean and a sample standard deviation. The run writes a console table, results.json, report.md, and report.html.

Video scoring is later. This version scores images. The video extra installs no packages, and there is no vbench metric.

  • Pluggable. Suites, metrics, and backends register by name. diffeval list and diffeval run look names up in TASKS, METRICS, and BACKENDS.
  • Light by default. The base install is PyYAML, Pillow, and NumPy. Torch, Diffusers, and clean-fid stay in optional extras.
  • Honest scores. A missing library or a missing reference is status skipped, with the reason stored on the row. The images stay on disk.
  • Traceable. results.json uses schema_version 1. It stores the suite, describe(), package versions, the GPU when torch reports one, and metric_protocols.

Installation

diffeval requires Python 3.10 or newer.

pip install diffeval

Add extras in brackets, for example pip install "diffeval[diffusers,metrics]". To work on the code, clone the repository and run pip install -e ".[dev]".

That installs the CLI, the YAML loader, Pillow, and NumPy.

Extra Installs Used for
diffusers torch, diffusers, transformers, accelerate, safetensors the diffusers backend
metrics torch, transformers, clean-fid, scipy<1.18 clip_score, cmmd, fid, kid
benchmarks pyarrow, huggingface_hub diffeval-coco30k-images
dev pytest the tests
geneval nothing keeps the GenEval detector off the default install
video nothing keeps VBench off the default install
pip install -e ".[diffusers,metrics]"
pip install -e ".[dev]"

The geneval metric returns skipped. The video extra does not install VBench.

Quickstart

Start with a CPU smoke run. The dummy backend draws deterministic RGB images, so the command downloads nothing.

diffeval run --backend dummy --suite core

If you omit both --backend and --pipeline, the backend is dummy. --pipeline without --backend selects diffusers.

Then a Diffusers model. Install the diffusers extra first. The command downloads weights. It has not been run in this repository, and CI does not run it. Without the extra, the process prints install the diffusers extra: pip install 'diffeval[diffusers]' and exits 2.

One smaller model has been run on a CPU. stabilityai/sd-turbo with --steps 1 --guidance 0 --device cpu generated all eight core images and scored clip_score, cmmd, fid, and kid, at about five seconds per image. That run says the backend and metrics work end to end. Its scores against the four core drawings are not quality numbers.

diffeval run --pipeline stabilityai/sd-turbo --suite core --steps 1 --guidance 0 --device cpu
diffeval run --pipeline black-forest-labs/FLUX.1-schnell --suite core

When --steps and --guidance are omitted, black-forest-labs/FLUX.1-schnell uses 4 steps and guidance 0. Any other model id leaves the pipeline defaults in place. A value passed on the CLI wins.

Each run writes a directory. The default is outputs/<UTC timestamp>-<suite>-<backend>. The timestamp looks like 20261025T153000Z. Spaces and slashes in that label become underscores. The model id stays in describe(). The folder name ends with the backend, dummy or diffusers.

outputs/20261025T153000Z-core-dummy/
├── images/
│   ├── seed_0/red_cube.png
│   └── seed_1/red_cube.png
├── results.json
├── report.md
└── report.html

core has four prompts, so each seed directory holds four PNGs. Paths inside results.json are relative to the output directory, for example images/seed_0/red_cube.png.

The console table and report.md have one row per metric. Columns are metric, status, mean, std, per-seed, and direction. With only the base install, the metrics are skipped:

metric      status   mean  std  per-seed  direction
clip_score  skipped  n/a   n/a  n/a,n/a   higher
cmmd        skipped  n/a   n/a  n/a,n/a   lower
fid         skipped  n/a   n/a  n/a,n/a   lower
kid         skipped  n/a   n/a  n/a,n/a   lower

Mean is the arithmetic mean of seeds whose status is ok. Standard deviation is the sample standard deviation, ddof=1. It is null when fewer than two seeds succeeded, and the console prints that null as n/a. The row stores std_ddof as 1. core uses two seeds so a real metric can show a standard deviation.

report.html repeats the table and shows an image grid grouped by prompt, one figure per seed. Prompts are escaped. The page says to check scores against the published reference implementation and dataset, and it calls core a smoke suite.

Exit code 0 means the report was written. Exit code 2 means the suite, backend, or metric name was unknown, generation failed, the chosen backend's extra is missing, or --strict found a metric that is not ok. --strict is off by default. The runner writes the report first, then exits 2. A smoke run with the metrics extra missing still exits 0.

diffeval list tasks
diffeval list metrics
diffeval list backends
diffeval run --backend dummy --suite core --seeds 0 --output outputs/smoke
diffeval run --backend dummy --suite core --metrics geneval --strict

The last command writes the report and exits 2. geneval is skipped, and --strict requires every aggregate status to be ok.

Command reference

diffeval list tasks
diffeval list metrics
diffeval list backends
diffeval run --suite NAME_OR_PATH [options]
Option Description
--suite A registered suite name, or a path ending in .yaml or .yml. Required. A bare name is looked up in TASKS.
--backend dummy or diffusers. Defaults to diffusers when --pipeline is set, otherwise dummy.
--pipeline Hugging Face model id. Required for the diffusers backend.
--steps, --guidance Sampler steps and guidance scale. FLUX.1-schnell presets to 4 steps and guidance 0. Other models use the pipeline defaults. CLI values win.
--dtype Requested dtype. On CPU, float16 and bfloat16 load as float32. describe() stores the dtype actually used in dtype and the flag in requested_dtype.
--device Device for the pipeline and for metrics. With no flag, metrics use CUDA when torch reports it, otherwise MPS, otherwise CPU. Without torch, metrics use CPU.
--attention sdpa, xformers, or eager. With no flag, the pipeline default stays.
--variant Diffusers pipeline variant.
--batch-size Positive integer. Default 1.
--seeds Comma-separated integers, overriding the suite. Example: --seeds 0,1,2.
--metrics Comma-separated metric names, overriding the suite.
--width, --height Image size in pixels, overriding the suite.
--output Output directory.
--strict Exit 2 unless every aggregate status is ok. The report is still written.

describe() also records steps_source and guidance_source as cli, preset, or pipeline-default.

Metrics

Metric Better Implementation Needs references
clip_score higher Hessel et al. 2021, CLIP ViT-B/32. Mean of 2.5 * max(cosine, 0) on the raw prompt, truncated to 77 tokens. no
cmmd lower Jayasumana et al. 2024, CLIP ViT-L/14 at 336, center square crop, L2-normalized vision embeddings. Minimum-variance RBF MMD, diagonal included, sigma 10, scaled by 1000. Matches the cmmd-pytorch sample check of 7.696. yes
fid lower clean-fid compute_fid, mode="clean", Inception-v3. clean-fid resizes each RGB image to 299×299. diffeval does not resize the PNG first. yes
kid lower clean-fid compute_kid on the same features. Degree-3 polynomial, 100 subsets, subset size at most 1000. yes
geneval higher Stub. Returns skipped. details.by_tag maps single_object, two_object, counting, colors, position, and color_attr to null. Mask2Former is not imported. no

The registered metrics are clip_score, cmmd, fid, kid, and geneval.

clip_score, cmmd, fid, and kid return skipped when their library is missing. fid, kid, and cmmd also skip when the suite has no reference. A reference is an image folder, precomputed clean_fid_stats for fid and kid, or a .npy CLIP embedding for cmmd. fid and kid also skip when the generated folder or the reference folder has fewer than two images. Both calls seed NumPy with the evaluation seed and restore the previous state. FID, KID, and CMMD set details.warning when the image count is below the published COCO setup of 30000. The metrics extra pins SciPy below 1.18: clean-fid 0.1.35 calls scipy.linalg.sqrtm with disp=False, which SciPy 1.18 removed, so fid and kid would error.

diffeval-check-cmmd downloads the six cmmd-pytorch sample images and checks that cmmd returns 7.696, the value that implementation documents. Earlier versions skipped the L2 normalization and the center crop, so their cmmd values are not comparable with published ones.

Benchmarks compares diffeval with published CMMD values and lists the commands to reproduce them.

Each metric's protocol dict is copied into metric_protocols in results.json.

How scores are aggregated

Status Meaning
ok every seed succeeded
partial some seeds succeeded
skipped every seed was skipped
error at least one seed failed and none succeeded

The mean uses successful seeds only. The standard deviation is null below two successful seeds, which the console prints as n/a.

Backends

Backend Description
dummy Deterministic RGB images. CI and the smoke command use it. describe() sets device to cpu and attention_backend to none.
diffusers AutoPipelineForText2Image. Each request gets its own CPU torch.Generator, seeded from that request.

fal and Replicate are not registered. v1 ships dummy and diffusers only.

Suites

A suite is a YAML file. A file that omits width or height gets 512 for each. A file that omits metrics gets clip_score, cmmd, fid, and kid. Prompt ids match [A-Za-z0-9_-]+, because they become file names.

name: shapes
description: Two prompts for a local check.
seeds: [0, 1]
width: 512
height: 512
metrics: [clip_score]
prompts:
  - {id: red_cube, prompt: a red cube}
  - {id: blue_sphere, prompt: a blue sphere}
diffeval run --backend dummy --suite path/to/shapes.yaml

The bundled core suite has four synthetic prompts (red_cube, blue_sphere, green_triangle, yellow_star), seeds [0, 1], 512×512 images, and small reference drawings under reference_dir. Those drawings are not COCO. A core score is a smoke check.

Extending diffeval

Importing diffeval loads the plugins. Each task, metric, and backend registers into TASKS, METRICS, or BACKENDS. Add a module, import it from the matching package __init__.py, and the name shows up in diffeval list.

Add a metric

The runner constructs the class with no arguments and calls compute(samples, context) once per seed. Return a MetricResult. Status ok carries a finite float. Status skipped or error carries a null value and an error string. protocol is copied into metric_protocols.

from diffeval.metrics.ok import ok
from diffeval.metrics.skipped import skipped
from diffeval.registry.register import register
from diffeval.registry.tables import METRICS


@register(METRICS, "example")
class Example:
    name = "example"
    description = "What the number means."
    higher_is_better = True
    requires_references = False
    protocol = {"formula": "state the formula here"}

    def compute(self, samples, context):
        try:
            import some_library
        except ImportError:
            return skipped(self.name, "install some_library", self.higher_is_better, self.protocol)
        value = ...  # a finite float for this seed
        return ok(self.name, value, self.higher_is_better, self.protocol)

A missing optional library returns skipped, with the reason in the error string.

Add a backend

The runner calls from_config(config) on the class, then prepare(), generate(requests), and describe().

generate returns one diffeval.types.sample.Sample per request, in request order. Sample.image is a PIL RGB image seeded from that request's seed. The runner writes it to a path like images/seed_0/red_cube.png.

describe() returns name, pipeline, dtype, requested_dtype, steps, guidance, steps_source, guidance_source, batch_size, device, attention_backend, and variant.

src/diffeval/backends/dummy/backend.py is the short example.

Register a named suite

To make a suite available by name, register an object with description and load(). The runner calls load() on that object. It does not construct the class. Follow src/diffeval/tasks/core.py, which registers an instance.

from diffeval.registry.register import register
from diffeval.registry.tables import TASKS
from diffeval.tasks.load_path import load_path


class Shapes:
    description = "Two prompts for a local check."

    def load(self):
        return load_path("path/to/shapes.yaml")


register(TASKS, "shapes")(Shapes())

To ship a suite with the package, put its YAML in src/diffeval/tasks/suites/ and import the module from src/diffeval/tasks/__init__.py.

Project layout

src/diffeval/
├── cli/        argument parsing and the list / run commands
├── tasks/      suite loading and the bundled suites
├── backends/   dummy and diffusers
├── metrics/    clip_score, cmmd, fid, kid, geneval
├── runner/     per-seed generation and scoring
├── aggregate/  mean, sample std, and status across seeds
├── report/     console, Markdown, and HTML
├── registry/   TASKS, METRICS, and BACKENDS
├── system/     package versions, GPU, and attention flags
└── types/      shared records

Every .py file in src/ and tests/ has at most 20 lines of code. Blank lines, comments, and docstrings do not count. Imports do. docs/DESIGN.md is the rule and the module tree. docs/ROADMAP.md is the split into pull requests.

Contributing

pip install -e ".[dev]"
pytest

CI runs that on Python 3.10, 3.11, and 3.12, then runs diffeval run --backend dummy --suite core.

Keep new behavior inside the line cap. Register tasks, metrics, and backends by name. Do not commit model weights. Do not report a smoke score as a paper result.

License

Apache-2.0. See LICENSE.

Metadata

Release files for diffeval 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for diffeval 0.1.0
File Size Uploaded Provenance Actions
diffeval-0.1.0.tar.gz 53.8 kB Without provenance Details for diffeval-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for diffeval 0.1.0
File Interpreter ABI Platform Actions
diffeval-0.1.0-py3-none-any.whl Python 3 none any Details for diffeval-0.1.0-py3-none-any.whl

Total release size: 140.0 kB

Release files / diffeval-0.1.0.tar.gz

Download URL diffeval-0.1.0.tar.gz
Size 53.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f4434eaf135b53097ee9123167d8e8435b69b5f1bf34d9bf37d5f2ff5363a0bd
BLAKE2b-256 checksum
How to use checksums
f7ddf6631633f618a84f5970711fde112db5b31016ab0e58df800f0a10013717
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / diffeval-0.1.0-py3-none-any.whl

Download URL diffeval-0.1.0-py3-none-any.whl
Size 86.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63f58579cf34df81d2d70c582234731bc0d0622b6637930ad31f4ead785aa141
BLAKE2b-256 checksum
How to use checksums
540ba73f3a8506cfd5fa58982bf292b49adec3984137757f6b603260f93ffd31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Security for diffeval 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page