Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Evaluation harness: README, a warning when compared runs used different metric models

Claude85e3e84ec018
diff --git a/scripts/eval/README.md b/scripts/eval/README.md
new file mode 100644
index 00000000..7eed1bf4
--- /dev/null
+++ b/scripts/eval/README.md
@@ -0,0 +1,385 @@
+# Fuobe evaluation harness
+
+`scripts/eval` measures the Fuobe Originals. You give it a suite of cases. It runs each case through a
+running Fuobe's REST API, downloads what comes back, scores it and writes a report. The report holds
+timing, cost, memory, metrics and a blind A/B review page. Runs are kept, so you can compare them.
+
+The rule it serves: **an Original's recipe becomes a default only after the harness has measured
+it** (see [The promote rule](#the-promote-rule)). The harness never changes a default by itself. A
+person does that in a reviewed commit.
+
+It works against any Fuobe, on three engines:
+
+| `--engine` | What runs | Cost |
+| --- | --- | --- |
+| `demo` | The demo provider's media. It checks the harness itself, with no keys and no GPU. | Free |
+| `open` | Your ComfyUI (the open engine), with the recipe's LoRAs. | Free (your GPU) |
+| `cloud` | Hosted open models on fal / Replicate that take LoRA URLs. Partner models run where a suite asks. | Priced before anything starts, under a spend cap (default $5) |
+
+## Quick start
+
+```bash
+pnpm dev # or any running Fuobe
+pnpm eval:run --suite selftest --engine demo # about 30 s, free: submit, wait, download, score, report
+pnpm eval:report latest # score again and rewrite the report
+open scripts/eval/results/<runId>/report.html # the contact sheet
+```
+
+A real look on your GPU, A/B against the same words without LoRAs and at half strength:
+
+```bash
+pnpm eval:run --suite soul --engine open --looks v1-general,v2-y2k-studio \
+ --variants recipe,prompt-only,half-strength --dry-run # lists the jobs, the LoRAs and the spend; starts nothing
+pnpm eval:run --suite soul --engine open --looks v1-general,v2-y2k-studio --variants recipe,prompt-only,half-strength
+pnpm eval:review latest # rate the pairs blind, with the keyboard
+pnpm eval:promote latest # does the recipe win?
+```
+
+`fuobe eval <command>` runs the same commands from the `fuobe` CLI (from a Fuobe checkout) and uses
+the CLI's saved server and token.
+
+### Which Fuobe it talks to
+
+The harness finds its server the way `bin/fuobe.mjs` does: `--url` / `--token`, then `FUOBE_URL` /
+`FUOBE_TOKEN`, then what `fuobe login` saved. A Fuobe with a password needs an API token from
+**Settings → Security → API tokens**. The token goes only to that server. Everything goes through
+the public API (`/api/generations`, `/api/uploads`, `/api/elements`, the studio routes), so the
+harness measures what a user gets.
+
+- `--engine demo` needs **Settings → Demo mode** on Auto or On. A job that would run for real is
+ skipped.
+- `--engine open` / `cloud` refuse a server whose engine mode excludes them. A job that would come
+ back as demo media is skipped and says why: Demo mode is On, no ComfyUI is connected, or there is
+ no cloud key.
+- On the open engine the harness also reads ComfyUI directly (`--comfy-url`, default `COMFYUI_URL`
+ or `http://127.0.0.1:8188`). It uses three read-only endpoints: `/system_stats` for memory,
+ `/history` for ComfyUI's own timings, and `/object_info/LoraLoader` to name the LoRAs ComfyUI
+ doesn't have yet. It never queues or cancels anything there.
+
+## Commands
+
+| Command | What it does |
+| --- | --- |
+| `pnpm eval:run --suite <s> --engine demo\|open\|cloud` | Runs a suite, then scores it and writes the report (`--no-metrics`, `--no-report` to stop earlier) |
+| `pnpm eval:report <runId\|latest>` | Scores again (only what changed) and rewrites `summary.json`, `report.html` and the history lines |
+| `pnpm eval:review <runId>` | Serves the blind A/B page and saves ratings next to the run |
+| `pnpm eval:compare <runA> <runB>` | Wins, losses and mean gain per metric. Exits 1 when a guarded metric regresses |
+| `pnpm eval:promote <runId>` | Applies the promote rule. `--record` writes the verdicts into the research JSON |
+| `pnpm eval:history` | Lists runs, newest first, and the per-case scores of one case (`--case soul/v1-general`) |
+| `pnpm eval:validate` | Checks every case file, and that the generated suites match the research |
+| `pnpm eval:setup` | Creates the metrics venv with uv (`--identity`, `--download`, `--dinov2`, `--torch-backend`) |
+
+Every command takes `--json`. Runs are named by id, by path, or as `latest`, `latest~1` (the run
+before) and so on. `pnpm eval:<command> --help` lists each command's options.
+
+Useful `run` options:
+
+- `--looks v1-general,"Flash editorial"`: looks by slug, name or id.
+- `--cases dop/motion-*`, `--tags v1,civitai`, `--limit 5`, `--prompts 1`, `--seeds 1,2`: run fewer
+ jobs.
+- `--variants recipe,prompt-only` or `all`: the recipe variants to run. Each suite has a default.
+- `--model <id>`: one model id for every job, instead of the suite's targets.
+- `--max-usd 2`: the cloud spend cap. The run is priced first. It refuses to start over the cap, and
+ it stops before a job would go over.
+- `--concurrency`: open 1, others 4.
+- `--resume <runId>`: runs only the failed and missing jobs again. Ctrl+C stops new jobs from
+ starting; the jobs already running finish on the server.
+- `--allow-fixtures`: uses the synthetic fixtures where your own inputs are missing.
+- `--label "after the LoRA strength change"`: a note kept with the run.
+
+## Suites
+
+One JSON file per Original in `cases/`. Later Original packages add their own files here.
+
+| Suite | Measures | Cases | Variants (default first) | Main metrics |
+| --- | --- | --- | --- | --- |
+| `selftest` | the harness itself | 5 small tools (trim, palette lock, join, frame, image) | — | temporal, clip |
+| `soul` | Fuobe Soul, the 139 looks | 139 looks × 3 subjects, pinned seeds | `recipe`, `prompt-only`, `half-strength`, `plain`, `original` | clip, aesthetic, style |
+| `soul-id` | character training | your photos → train → 8 scenes | `trained`, `original` | identity, clip, aesthetic |
+| `dop` | DoP motions and effects | the 70 the research gives a LoRA | `catalog`, `prompt-only`, `research`, `partner` | temporal, clip |
+| `genjutsu` | Genjutsu move / swap / restyle | 3 (through `/api/genjutsu`) | `original`, `partner` | temporal, clip |
+| `mixed-media` | Mixed Media | 5 looks on one clip (through `/api/mixed-media`) | `studio` | temporal, style |
+| `shorts` | Shorts restyle | 1 | `restyle` | temporal, style, clip |
+| `speak` | talking portraits | 1 portrait + voice | `infinitetalk`, `s2v` | lipsync, temporal, identity |
+| `cinema` | Cinema shot lists | 2 films of 3 shots | `original`, `partner` | clip, temporal, continuity |
+
+`soul.json` and `dop.json` are **generated** from the research. They come from
+`docs/research/higgsfield-image-studios.json` (the look ids) and
+`docs/research/fuobe-originals-recipes-5.json` (recipes, LoRAs, the motion map). Run
+`node scripts/eval/gen-cases.mjs` after the research changes, and don't edit the generated files by
+hand. `pnpm eval:validate` fails when they are out of date. The subject prompts are Fuobe's own. No
+Higgsfield prompt or preview is used anywhere.
+
+Soul variants, all on the same subjects and seeds:
+
+- **recipe**: the look's template, its LoRA triggers, and its LoRAs at the listed strengths.
+- **prompt-only**: the same words without LoRAs. Does each LoRA earn its slot?
+- **half-strength**: every LoRA at half strength. This is the over-cooking check.
+- **plain**: the base model with the subject alone.
+- **original**: the shipped `fuobe-soul` Original, which applies the look on the server. It is
+ skipped until that Original exists.
+
+### Licence rules in the runs
+
+The recipe's licence flags go with every job, following the research's "Licence rules for
+Originals":
+
+- A LoRA whose licence forbids hosted use never goes to the cloud engine.
+- A civitai link is left out on the cloud until a mirrored copy exists, because civitai answers 401
+ without your token.
+- A non-commercial LoRA is noted, and a recipe that uses one can't be promoted.
+
+A job records which LoRAs it asked for, which ones the route actually loaded, and which ones were
+left out and why.
+
+## Your own inputs: `scripts/eval/local/`
+
+Inputs the repo can't ship live in `scripts/eval/local/`, which is git-ignored and never committed.
+That covers photos of people, reference clips, licensed style references and voices. Cases name them
+as `local/…`. A job whose local input is missing is skipped and names the file. Demo runs use the
+small synthetic files in `fixtures/` instead.
+
+```
+scripts/eval/local/
+ references/soul/<look-slug>/*.jpg # style references per look (your own or licensed images; never Higgsfield previews)
+ references/mixed-media/<look>/* # what each Mixed Media look should look like
+ characters/default/*.jpg # 10–30 photos of ONE consenting person (soul-id)
+ dop/start.png, dop/end.png # a start frame (a person on a bridge fits the prompts), an end frame for transitions
+ genjutsu/dance.mp4, character.png, style.png
+ mixed-media/clip.mp4
+ shorts/clip.mp4, shorts/frame0.png
+ speak/portrait.png, speak/voice.wav
+```
+
+**Training needs consent.** `soul-id.json` ships with `"consent": false`, so training refuses to
+start. Copy the file to `local/soul-id.json`. In your copy, set `"consent": true` only when the
+person in the photos agreed. Then run it with `--suite scripts/eval/local/soul-id.json`. To reuse a
+character you already trained, put its element id in `"element"` instead of training again.
+
+## The case format
+
+A suite file follows `cases/case.schema.json`, which editors use for completion. The schema is
+written from `lib/schema.mjs`.
+
+```jsonc
+{
+ "$schema": "./case.schema.json",
+ "suite": "my-original",
+ "title": "Fuobe Something",
+ "description": "What it measures and what it needs.",
+ "original": "fuobe-something", // the Original(s) measured
+ "kind": "image", // image | video | audio
+ "recipe": "none", // soul-look | motion | none: where a case's recipe comes from
+ "targets": { // model ids per engine, in order of preference:
+ "open": { "models": ["fuobe-something", "oss-z-image-turbo"] }, // the first one this Fuobe has is used
+ "cloud": { "models": ["z-image-turbo-cloud"], "extra": { "num_inference_steps": 8 } },
+ "demo": { "models": ["oss-z-image-turbo"] }
+ },
+ "defaults": { "seeds": [1001], "metrics": ["clip", "aesthetic"], "timeoutSeconds": 1800 },
+ "variants": {
+ "recipe": { "description": "The recipe as researched", "loras": "recipe" },
+ "half": { "description": "Half strength", "loras": "recipe", "loraScale": 0.5 },
+ "mine": { "loras": [{ "file": "my-lora.safetensors", "url": "https://huggingface.co/…", "strength": 0.8, "trigger": "myword" }] }
+ },
+ "cases": [
+ {
+ "id": "my-original/portrait",
+ "title": "A portrait",
+ "prompts": [{ "id": "p1", "text": "a woman reading by a window", "seed": 1001 }],
+ "references": "local/references/my-original/portrait", // a folder or a list of files
+ "inputs": { "images": ["local/my-original/face.png"] }, // images, video, videos, audio, endImage, mask…
+ "demoInputs": { "images": ["fixtures/start-frame.png"] },
+ "params": { "aspectRatio": "3:4" }
+ }
+ ]
+}
+```
+
+Other case fields:
+
+- `look` / `motion`: a Soul look id, or a motion or effect name. The recipe comes from the
+ research.
+- `presetId`: a catalog preset.
+- `models` / `op`: per-case models, and the operation.
+- `shots`: a film's shots. Continuity is measured across them.
+- `train`: photos, a target per engine, `consent`, and `minPhotos`.
+- `submit`: a studio route and its body, with `{{inputs.video}}`, `{{source:inputs.video}}`,
+ `{{prompt}}`, `{{seed}}`, `{{engine}}` and `{{requestId}}` filled in.
+- `engines`: the engines the case runs on.
+- `tags`, `metrics` and `note`.
+
+Paths can start with:
+
+- `local/…`: your own inputs.
+- `fixtures/…`: the synthetic fixtures.
+- `samples/…`: `public/samples`.
+- Anything else is a path relative to the case file, an absolute path, or a link.
+
+Run `pnpm eval:validate` after editing.
+
+## What a run records
+
+Everything goes to `scripts/eval/results/` (git-ignored; move it with `--out` or `FUOBE_EVAL_RESULTS`):
+
+```
+results/
+ history.jsonl # one line per run × case × variant: mean scores (pnpm eval:history)
+ <runId>/
+ run.json # suite, engine, filters, variants, the server and ComfyUI it ran on,
+ # git commit, the research files' hashes, spend cap and spend
+ jobs.jsonl # one row per job, appended as each one ends (see below)
+ outputs/<jobId>/… # the downloaded results
+ metrics.json # scores per job (and per film), which model made them, at which revision, under which licence
+ summary.json # means per variant, variant-against-variant wins, blind ratings, failures
+ report.html # the contact sheet: every case × variant with its scores (light and dark, phone-friendly)
+ review/index.html # the blind A/B page; review/key.json (which side was which) is never served
+ review/ratings.json # your ratings
+ promote.json # the promote verdicts
+```
+
+Each row in `jobs.jsonl` records:
+
+- the case, prompt, seed and variant;
+- the model id asked for and the one that ran;
+- the route (`provider`, `endpoint`) and the final prompt;
+- the recipe: look or motion, template, the LoRAs with their strengths, which LoRAs the route loaded
+ and which it dropped and why, the sampler settings, and the licence flags;
+- the generation ids and the downloaded files;
+- the time: submitted, finished, wall clock;
+- the cost: the estimate before running and the cost after;
+- on the open engine: peak memory from `/system_stats` (CPU ComfyUIs are marked as RAM, not VRAM)
+ and ComfyUI's own execution time from `/history`;
+- notes and errors.
+
+## Metrics
+
+The metrics are written in Python (`metrics/fuobe_metrics`). Each metric is a small module with
+tests on tiny fixtures. They run on the CPU by default (`--device cuda|mps|auto` to change that).
+`pnpm eval:setup` creates the venv with [uv](https://docs.astral.sh/uv/) from the pinned
+`metrics/requirements.txt`, which is compiled from `requirements.in` with CPU torch.
+`--download` fetches the weights now; otherwise they download on first use. Every weight is pinned
+to a Hugging Face revision, and its licence is recorded with every result. Without Python, a run
+still has its timing and cost, and the report says why the scores are missing.
+
+| Metric | Key(s) | Better | How | Model and licence |
+| --- | --- | --- | --- | --- |
+| Prompt adherence | `clip` | higher | CLIPScore (100·cos) between the output and the case's own words. Clips are sampled at 4 frames | open_clip ViT-B/32 laion2B, **MIT** (`--clip-model clip-l14`: OpenAI ViT-L/14, MIT) |
+| Aesthetic | `aesthetic` | higher | LAION improved aesthetic predictor v2 on CLIP ViT-L/14 embeddings, about 1–10 | head **Apache-2.0** (christophschuhmann/improved-aesthetic-predictor), CLIP MIT |
+| Style vs references | `style`, `styleNearest` | higher | cosine of the output's embedding to the centroid of the look's reference set, and to the nearest reference | CLIP (default), or `--style-model dinov2`: DINOv2 ViT-S/14 via timm, **Apache-2.0** |
+| Identity | `identity`, `faceRate` | higher | ArcFace-style face embeddings of the output against the person's photos; the share of frames with a face | **AuraFace v1** (fal, **Apache-2.0**, trained for commercial use) by default. insightface's `buffalo_l` is **non-commercial research only**: opt in with `--identity-model buffalo_l --accept-noncommercial` |
+| Temporal consistency | `drift`, `driftMax`, `warp` | lower | frame-to-frame CLIP embedding drift (mean and worst jump), and a warp error: Farneback optical flow with a forward-backward occlusion mask | CLIP, OpenCV (Apache-2.0) |
+| Lip-sync | `lipsync`, `lipsyncOffset` | higher | a proxy: mouth-region motion against the voice's loudness, with the best lag as the A/V offset | AuraFace's detector for the face box when identity is installed, else a fixed lower-centre region |
+| SyncNet (optional) | `syncnet` | higher | runs only when `FUOBE_EVAL_SYNCNET_CMD` points at your own SyncNet. It isn't bundled because its weights' licence isn't stated | yours |
+| Shot continuity | `continuity` | higher | CLIP similarity between consecutive shots of a film | CLIP |
+| Time, cost, memory | `seconds`, `costUsd`, `vramGb` | lower | from the runner | — |
+
+Identity needs `pnpm eval:setup --identity`, which installs insightface and onnxruntime (MIT
+libraries). Re-scoring is incremental: a job whose outputs and settings haven't changed keeps its
+scores. `--metrics clip,style` re-scores only those families and keeps the others. `--force`
+re-scores everything.
+
+The metrics are signals, not verdicts. CLIP rewards literal prompt matches. The aesthetic predictor
+has its own taste. Style needs references that really show the look. That is why promotion also
+needs people's ratings.
+
+## Blind A/B review
+
+`pnpm eval:review <runId>` writes `review/index.html` and serves it at `http://127.0.0.1:4173`. The
+page shows two results side by side. Their order comes from a hash, and nothing on the page names
+the variant, model or file.
+
+- `--against variants` is the default when the run has two or more variants. It pairs the first
+ variant with each of the others on the same case, prompt and seed.
+- `--against references` is the default otherwise. It pairs each output with one of your references
+ from `local/references/…`.
+- `--against <otherRunId>` pairs the same jobs across two runs, for example before and after a
+ change.
+
+Use **←** / **1** for the left result, **→** / **2** for the right one, **↓** / **0** / **Space**
+for "about the same", **S** to skip and **U** / **Backspace** to undo. On a phone, use the three
+buttons. Ratings save to `review/ratings.json` as you go. Opened as a plain file, the page keeps
+them in the browser and offers a download. `pnpm eval:report` unblinds the ratings with
+`review/key.json` and adds the preference per variant pair to `summary.json`.
+
+## Comparing runs and catching regressions
+
+```bash
+pnpm eval:compare latest~1 latest # wins / losses / ties and mean gain per metric
+pnpm eval:compare base-run new-run --fail-on clip,style --threshold 5% # exit 1 when either mean drops by more than 5 %
+pnpm eval:compare run:prompt-only run:recipe --fail-on style # two variants of one run
+pnpm eval:compare a b --fail-on warp --per-case # also fail on any single case's regression
+```
+
+Compare matches jobs on case, prompt, seed and variant. `--threshold` can be an absolute amount in
+the metric's units, or a percentage of A's mean. Without it, each metric's own noise band applies
+(`lib/metric-info.mjs`). A guarded metric with no scores in both runs counts as a failure, so the
+check can't pass just because the metric never ran. Every report appends its per-case means to
+`results/history.jsonl`, and `pnpm eval:history --case soul/v1-general` shows a case over time.
+
+## The promote rule
+
+A recipe (the candidate variant, `recipe` by default) is **eligible** to become a look's default
+only when one run, on the same prompts and seeds, shows all of the following:
+
+1. **Licence**: every LoRA it loaded is commercial, and is hostable when the run is on the cloud.
+ None of the recipe's LoRAs was left out on that engine.
+2. **Enough results**: at least 3 for the look.
+3. **Metrics**: against every alternative in the run (prompt only, half strength, the bare base,
+ today's default), it scores at least as well on the look's main metric. That is style when the
+ look has references, else aesthetic. It also gives up no more than 1.0 CLIP or 0.15 aesthetic.
+4. **People**: at least 6 blind ratings against the alternatives, with at least 55 % of the non-tie
+ ratings going to the candidate.
+
+If half strength wins, the verdict is **lower strengths**, not another recipe: the LoRAs over-cook,
+so lower them in the research JSON and run again. Demo runs never promote anything. A run on one
+engine says to check the other engine too.
+
+`pnpm eval:promote <runId>` writes `promote.json`. `--record` also writes each case's verdict into
+the research JSON (`docs/research/fuobe-originals-recipes-5.json`). The verdict goes in the `eval`
+list of the entry it measured: a Soul look's `presets[]` entry, or a motion's `motionsEffects[]`
+entry. Each record holds:
+
+- the run, the engine and the date;
+- the verdict and the reasons for it;
+- the main metric against each alternative;
+- the LoRAs it ran, and the strengths to try when half strength won.
+
+A newer record for the same engine and case replaces the older one. The file keeps its format, so
+the diff shows only the records. Recording never changes a recipe, a strength or a default. Those
+remain code changes that a person reviews:
+
+1. Edit the research JSON.
+2. Regenerate the catalog.
+3. Check both engines.
+
+## Tests
+
+- `tests/eval-harness.test.ts` (Vitest) covers several areas:
+ - The runner runs end to end against Fuobe's real route handlers, served over HTTP, with the demo
+ provider: plan, price, upload, submit, wait, download and record.
+ - A studio route (Genjutsu), and a training case.
+ - The engine checks, the spend cap, `--resume` and the dry run.
+ - Case-file validation.
+ - Report, blind review, compare (with its exit codes), promote and `--record`.
+- `tests/eval-api.test.ts` covers the API seams the harness needs: a recipe's LoRAs on
+ `POST /api/generations`, and a preview that says which LoRAs the route loads.
+- `tests/eval-metrics.test.ts` runs the Python tests (`metrics/tests`, pytest) in the metrics venv,
+ or through uv. Without either, they are skipped. The maths tests use numpy only. The media tests
+ need ffmpeg. The model tests run when their weights are cached.
+- `tests/e2e/eval-review.mjs` checks the report and review pages in a browser at 1440 and 390 px,
+ light and dark, and rates every pair with the keyboard.
+
+```bash
+pnpm vitest run tests/eval-harness.test.ts tests/eval-api.test.ts tests/eval-metrics.test.ts
+cd scripts/eval/metrics && .venv/bin/python -m pytest -q tests
+```
+
+## Adding an Original's cases
+
+1. Add `cases/<original>.json`. Use `selftest.json` or `genjutsu.json` as a model, depending on
+ whether the Original runs through `/api/generations` or through a studio route.
+2. Name targets per engine. Put the Original's model id first and today's base model after it, so
+ the suite runs now and switches to the Original once it exists.
+3. Put inputs the repo can't ship under `local/…`, with small `demoInputs` from `fixtures/`.
+4. Choose metrics. Add references if style or identity matter.
+5. Run `pnpm eval:validate`, then `pnpm eval:run --suite <original> --engine demo`.
diff --git a/scripts/eval/eval.mjs b/scripts/eval/eval.mjs
index d4a805c1..b7b8c679 100644
--- a/scripts/eval/eval.mjs
+++ b/scripts/eval/eval.mjs
@@ -330,6 +330,7 @@ async function history(args, ctx) {
async function validate(args, ctx) {
const { values: v, positionals } = parse(args, {}, { positionals: true });
+ if (v.help) return ctx.print(HELP.validate), 0;
const results = validateAll(positionals.length ? positionals.map((p) => path.resolve(p)) : suiteFiles());
let bad = results.filter((r) => !r.ok).length;
const { generated } = await import("./gen-cases.mjs");
@@ -351,6 +352,7 @@ async function validate(args, ctx) {
async function setup(args, ctx) {
const { values: v } = parse(args, { identity: { type: "boolean" }, dinov2: { type: "boolean" }, download: { type: "boolean" }, "torch-backend": { type: "string" } });
+ if (v.help) return ctx.print(HELP.setup), 0;
const step = (cmd, a, opts = {}) => {
ctx.note(`$ ${cmd} ${a.join(" ")}`);
const r = spawnSync(cmd, a, { cwd: METRICS_DIR, stdio: "inherit", env: ctx.env, ...opts });
diff --git a/scripts/eval/lib/compare.mjs b/scripts/eval/lib/compare.mjs
index 868d324e..8be0a7d1 100644
--- a/scripts/eval/lib/compare.mjs
+++ b/scripts/eval/lib/compare.mjs
@@ -91,7 +91,18 @@ export function compareRuns(a, b, opts = {}) {
}
}
}
+ // Scores made by different metric models don't compare (CLIP vs DINOv2 style, B/32 vs L/14 CLIP…).
+ const warnings = [];
+ const ca = A.metrics?.config ?? {};
+ const cb = B.metrics?.config ?? {};
+ for (const [k, label] of [["clip", "CLIP model"], ["style", "style model"], ["identity", "face model"]]) {
+ // metrics.json from before --style-model scored style with CLIP.
+ const x = ca[k] ?? (k === "style" && A.metrics ? "clip" : null);
+ const y = cb[k] ?? (k === "style" && B.metrics ? "clip" : null);
+ if (x != null && y != null && x !== y) warnings.push(`the runs were scored with a different ${label} (${x} vs ${y}): rescore one with pnpm eval:report --force and the same options`);
+ }
return {
+ warnings,
a: { runId: A.run.runId, suite: A.run.suite, engine: A.run.engine, variant: va },
b: { runId: B.run.runId, suite: B.run.suite, engine: B.run.engine, variant: vb },
matched: keys.length,
@@ -121,6 +132,7 @@ const signed = (metric, g) => `${g >= 0 ? "+" : "−"}${fmt(metric, Math.abs(g))
export function compareText(c) {
const name = (x) => `${x.runId}${x.variant ? `:${x.variant}` : ""} (${x.suite} · ${x.engine})`;
const lines = [`A ${name(c.a)}`, `B ${name(c.b)}`, `${c.matched} jobs in both${c.onlyA || c.onlyB ? ` · ${c.onlyA} only in A · ${c.onlyB} only in B` : ""}`, ""];
+ for (const w of c.warnings ?? []) lines.push(`! ${w}`, "");
if (!c.metrics.length) lines.push("No scores to compare (run pnpm eval:report on both runs first).");
const w = Math.max(10, ...c.metrics.map((r) => r.label.length));
if (c.metrics.length) lines.push(`${"metric".padEnd(w)} ${"A".padStart(9)} ${"B".padStart(9)} ${"B better".padStart(8)} ${"worse".padStart(5)} ${"same".padStart(4)} gain`);
diff --git a/tests/e2e/eval-review.mjs b/tests/e2e/eval-review.mjs
index 61c0e589..a3def699 100644
--- a/tests/e2e/eval-review.mjs
+++ b/tests/e2e/eval-review.mjs
@@ -90,16 +90,22 @@ try {
page.on("pageerror", (e) => errors.push(e.message));
await page.goto(pathToFileURL(path.join(runDir, "report.html")).href, { waitUntil: "load" });
+ // The contact sheet's pictures load lazily: bring each into view (a run of clips may have one picture at the end).
+ await page.evaluate(async () => {
+ for (const m of document.querySelectorAll("img, video")) m.scrollIntoView({ block: "center" });
+ await Promise.all([...document.images].map((i) => i.decode().catch(() => {})));
+ window.scrollTo(0, 0);
+ });
await page.waitForTimeout(300);
const report = await page.evaluate(() => ({
overflow: document.scrollingElement.scrollWidth - window.innerWidth,
bg: getComputedStyle(document.body).backgroundColor,
- imgs: [...document.images].filter((i) => i.complete && i.naturalWidth > 0).length,
+ imgs: [...document.images].filter((i) => i.complete && i.naturalWidth > 0).length + [...document.querySelectorAll("video")].filter((v) => v.readyState >= 1).length,
h1: document.querySelector("h1")?.textContent,
}));
check(report.overflow <= 0, `report ${name} ${scheme}: no sideways scroll (${report.overflow}px over)`);
check(scheme === "dark" ? report.bg === "rgb(9, 9, 11)" : report.bg === "rgb(255, 255, 255)", `report ${name} ${scheme}: ${scheme} background (${report.bg})`);
- check(report.imgs > 0, `report ${name} ${scheme}: ${report.imgs} images load`);
+ check(report.imgs > 0, `report ${name} ${scheme}: ${report.imgs} pictures and clips load`);
await page.screenshot({ path: path.join(shots, `report-${name}-${scheme}.png`), fullPage: false });
await page.goto(url, { waitUntil: "load" });
diff --git a/tests/eval-harness.test.ts b/tests/eval-harness.test.ts
index 91460d1e..b8071947 100644
--- a/tests/eval-harness.test.ts
+++ b/tests/eval-harness.test.ts
@@ -438,6 +438,15 @@ describe("report, blind review, compare and promote", () => {
const unknown = await cli(["compare", "fake-open-1", "fake-open-3", "--fail-on", "smell"]);
expect(unknown.code).toBe(1);
expect(unknown.stderr).toMatch(/Unknown metric “smell”/);
+ // Scores from different metric models are flagged, not silently compared.
+ const m3 = path.join(results, "fake-open-3", "metrics.json");
+ const saved = fs.readFileSync(m3, "utf8");
+ fs.writeFileSync(m3, JSON.stringify({ ...JSON.parse(saved), config: { clip: "clip-b32", style: "dinov2" } }));
+ try {
+ expect((await cli(["compare", "fake-open-1", "fake-open-3"])).stdout).toMatch(/^! the runs were scored with a different style model \(clip vs dinov2\)[^\n]*\n\nmetric/m);
+ } finally {
+ fs.writeFileSync(m3, saved);
+ }
});
it("fuobe eval hands its arguments to the harness, with the CLI's server and token", async () => {