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: the blind review serves both sounds of a pair as FLAC, so the file type doesn't say which model made it

Claudeffb141f9e5ff
diff --git a/scripts/eval/lib/review.mjs b/scripts/eval/lib/review.mjs
index 7ef91ce3..cbd95948 100644
--- a/scripts/eval/lib/review.mjs
+++ b/scripts/eval/lib/review.mjs
@@ -4,6 +4,7 @@
// keyboard; ratings land in review/ratings.json (pnpm eval:review serves the page and saves them;
// opened as a file it keeps them in the browser and offers a download). review/key.json, which the
// page never loads, says which side was which; the summary unblinds the ratings with it.
+import { spawnSync } from "node:child_process";
import crypto from "node:crypto";
import fs from "node:fs";
import http from "node:http";
@@ -14,6 +15,13 @@ import { candidateOf, latestJobs, readJson, writeJson } from "./store.mjs";
const IMAGE = /\.(png|jpe?g|webp|gif|svg)$/i;
const VIDEO = /\.(mp4|mov|m4v|webm)$/i;
const AUDIO = /\.(flac|wav|mp3|m4a|ogg)$/i;
+/** The one format a blind audio pair is served in (lossless; every current browser plays it). */
+const AUDIO_EXT = ".flac";
+/** A sound re-encoded as FLAC for the review; false when ffmpeg can't (the file is then served as it is, under the FLAC name). */
+function toAudio(file, dest) {
+ const r = spawnSync("ffmpeg", ["-v", "error", "-y", "-i", file, "-vn", "-c:a", "flac", dest], { stdio: "ignore" });
+ return r.status === 0 && fs.existsSync(dest);
+}
const hash = (s) => crypto.createHash("sha256").update(s).digest("hex");
/** The first picture or clip of a succeeded row (helpers like masks left out); a separation's first stem. */
@@ -98,21 +106,26 @@ export function writeReview(run, opts = {}) {
fs.rmSync(mediaDir, { recursive: true, force: true });
fs.mkdirSync(mediaDir, { recursive: true });
const placed = new Map();
- const place = (file) => {
- if (placed.has(file)) return placed.get(file);
- const name = `${hash(`media|${file}`).slice(0, 10)}${path.extname(file).toLowerCase()}`;
+ const place = (file, audio = false) => {
+ const key = `${audio ? "a" : "m"}|${file}`;
+ if (placed.has(key)) return placed.get(key);
+ const name = `${hash(`media|${file}`).slice(0, 10)}${audio ? AUDIO_EXT : path.extname(file).toLowerCase()}`;
const dest = path.join(mediaDir, name);
- try {
- fs.linkSync(file, dest);
- } catch {
- fs.copyFileSync(file, dest);
+ if (!audio || path.extname(file).toLowerCase() === AUDIO_EXT || !toAudio(file, dest)) {
+ try {
+ fs.linkSync(file, dest);
+ } catch {
+ fs.copyFileSync(file, dest);
+ }
}
- placed.set(file, `media/${name}`);
+ placed.set(key, `media/${name}`);
return `media/${name}`;
};
const items = pairs.map((p) => {
const [left, right] = p.aLeft ? [p.a, p.b] : [p.b, p.a];
- return { id: p.id, prompt: p.prompt ?? "", title: p.caseTitle ?? "", left: place(left.file), right: place(right.file), video: [left.file, right.file].some((f) => VIDEO.test(f)), audio: [left.file, right.file].every((f) => AUDIO.test(f)) };
+ // Two sounds are served in one format, so a file type (DBS's FLAC against MelBand's MP3) can't say which is which.
+ const audio = [left.file, right.file].every((f) => AUDIO.test(f));
+ return { id: p.id, prompt: p.prompt ?? "", title: p.caseTitle ?? "", left: place(left.file, audio), right: place(right.file, audio), video: [left.file, right.file].some((f) => VIDEO.test(f)), audio };
});
writeJson(path.join(out, "key.json"), {
runId: run.runId,
diff --git a/tests/eval-harness.test.ts b/tests/eval-harness.test.ts
index 491b58d5..65d7a27c 100644
--- a/tests/eval-harness.test.ts
+++ b/tests/eval-harness.test.ts
@@ -346,7 +346,7 @@ describe("the runner on the demo provider", () => {
});
it("runs each Genjutsu mode's own partner model on fal", async () => {
- type Plan = { jobs: { case: string; variant: string; model: string; skip?: string }[] };
+ type Plan = { jobs: { case: string; variant: string; model: string; skip?: string; costUsd?: number | null }[] };
const dry = async (args: string[]) => JSON.parse((await cli(["run", ...args, "--dry-run", "--json"])).stdout) as Plan;
setSetting("falKey", "fal-test-key");
try {
@@ -386,6 +386,17 @@ describe("the runner on the demo provider", () => {
["shorts/session", "fuobe-shorts", null],
["shorts/session", "fuobe-shorts", null],
]);
+ // Clean up dialogue's hosted cleaners: planned and priced as dry runs, each on its own op.
+ const sep = await dry(["--suite", "separation", "--engine", "cloud", "--variants", "clean-veed,clean-deepfilternet,demucs", "--cases", "separation/centre,separation/video", "--allow-fixtures"]);
+ expect(sep.jobs.map((j) => [j.case, j.variant, j.model, j.skip ? "refused" : typeof j.costUsd])).toEqual([
+ ["separation/centre", "clean-veed", "veed-clean-audio", "number"],
+ ["separation/centre", "clean-deepfilternet", "deepfilternet3", "number"],
+ ["separation/centre", "demucs", "demucs", "number"],
+ // VEED takes a video's file itself; DeepFilterNet 3 and Demucs take audio only.
+ ["separation/video", "clean-veed", "veed-clean-audio", "number"],
+ ["separation/video", "clean-deepfilternet", "deepfilternet3", "refused"],
+ ["separation/video", "demucs", "demucs", "refused"],
+ ]);
const shp = await dry(["--suite", "shorts", "--engine", "cloud", "--variants", "partner", "--seeds", "1001", "--allow-fixtures"]);
expect(shp.jobs.map((j) => [j.case, j.model, j.skip ?? null])).toEqual([
["shorts/segment", "gemini-omni-flash", null],
@@ -437,6 +448,12 @@ describe("the runner on the demo provider", () => {
["demucs", "oss-dbs-separate", null, null, "the demucs variant runs on cloud only"],
]);
expect(jobs.every((j) => j.request.op === "separate-audio")).toBe(true);
+ // Clean up dialogue on the open engine: graph C with the music and effects at −18 dB; the cloud cleaners run enhance-voice.
+ const clean = plan.expandJobs(suite, { engine: "open", variants: ["clean-dialogue", "clean-veed"], cases: ["separation/hiss"], exists: () => true }) as unknown as typeof jobs;
+ expect(clean.map((j) => [j.variant, j.request.modelId, j.request.op, j.request.params.extra ?? null, j.skip ?? null])).toEqual([
+ ["clean-dialogue", "oss-dbs-remix", "separate-audio", { separationModel: "DBS-BSRNN-DnR", channels: "mono", voiceDb: 0, musicDb: -18, effectsDb: -18 }, null],
+ ["clean-veed", "oss-dbs-separate", "enhance-voice", null, "the clean-veed variant runs on cloud only"],
+ ]);
// The cloud runs Demucs as today's cloud dub does; DBS isn't hosted, so its variants say they run on the open engine.
const cloud = plan.expandJobs(suite, { engine: "cloud", variants: ["demucs", "bsrnn-mono"], cases: ["separation/centre"], exists: () => true }) as unknown as { variant: string; skip?: string; request: { modelId: string } }[];
expect(cloud.map((j) => [j.variant, j.request.modelId, j.skip ?? null])).toEqual([
@@ -598,6 +615,31 @@ describe("report, blind review, compare and promote", () => {
expect(html).toContain("prefers-color-scheme: dark");
});
+ it("serves both sounds of a blind pair in one format, so the file type doesn't give the model away", () => {
+ if (spawnSync("ffmpeg", ["-version"]).status !== 0) return; // re-encoding needs ffmpeg
+ const runDir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-review-audio-"));
+ const tone = (file: string) => spawnSync("ffmpeg", ["-v", "error", "-y", "-f", "lavfi", "-i", "sine=frequency=440:duration=0.5", path.join(runDir, file)]);
+ const rows = [
+ ["dbs-dub", ".flac"],
+ ["melband", ".mp3"],
+ ].map(([variant, ext]) => {
+ fs.mkdirSync(path.join(runDir, variant), { recursive: true });
+ for (const stem of ["voice", "background"]) tone(`${variant}/${stem}${ext}`);
+ return { id: `separation__centre--p1--s1001--${variant}`, key: "separation/centre/p1/s1001", variant, status: "succeeded", caseId: "separation/centre", caseTitle: "Centre", outputs: ["voice", "background"].map((stem) => ({ file: `${variant}/${stem}${ext}`, kind: "audio", stem })) };
+ });
+ fs.writeFileSync(path.join(runDir, "run.json"), JSON.stringify({ candidate: "dbs-dub" }));
+ try {
+ expect(review.writeReview({ dir: runDir, runId: "fake-sep", rows }).pairs).toBe(2);
+ const media = fs.readdirSync(path.join(runDir, "review", "media"));
+ expect(media).toHaveLength(4);
+ expect(media.every((f) => f.endsWith(".flac"))).toBe(true);
+ for (const f of media) expect(spawnSync("ffprobe", ["-v", "error", "-show_entries", "format=format_name", "-of", "csv=p=0", path.join(runDir, "review", "media", f)], { encoding: "utf8" }).stdout.trim()).toBe("flac");
+ expect(fs.readFileSync(path.join(runDir, "review", "index.html"), "utf8")).not.toMatch(/\.mp3|melband|dbs-dub/);
+ } finally {
+ fs.rmSync(runDir, { recursive: true, force: true });
+ }
+ });
+
it("builds blind pairs whose page doesn't say which side is which, saves ratings and unblinds them in the summary", async () => {
const runDir = path.join(results, "fake-open-1");
const rows = store.latestJobs(runDir);