cozyclay 1.9.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +171 -0
- package/bin/agent/agent-routes.mjs +74 -70
- package/bin/agent/agent-runner.mjs +10 -3
- package/bin/agent/motion-runtime.mjs +32 -260
- package/bin/agent/providers.mjs +46 -3
- package/bin/agent/session-store.mjs +41 -5
- package/bin/agent/studio-prompt.mjs +1 -1
- package/bin/agent/studio-tools.mjs +48 -11
- package/bin/cozyclay.mjs +26 -8
- package/bin/live/cli.mjs +22 -3
- package/bin/mcp-runtime.mjs +35 -20
- package/bin/telemetry-state.mjs +5 -2
- package/bin/update-check.mjs +15 -0
- package/dist/app/index.html +6 -6
- package/dist/assets/analytics-MVZOEW8O.js +1 -0
- package/dist/assets/app-C1sdVbg4.css +1 -0
- package/dist/assets/app-CA55tcI3.js +4876 -0
- package/dist/assets/{demo-B-eg1CT8.js → demo-ByeYp-dY.js} +1 -1
- package/dist/assets/{first-shot-handoff-CGgnvNu8.js → first-shot-handoff-DgT28ZiV.js} +1 -1
- package/dist/assets/{landing-IbRp3FnQ.js → landing-BaXkpFip.js} +1 -1
- package/dist/assets/shot-prompt-CbqWcWYi.css +1 -0
- package/dist/assets/shot-prompt-Yrt99wZx.js +17 -0
- package/dist/assets/{ticket-BgIzOBOf.js → ticket-BcmsnHn5.js} +1 -1
- package/dist/assets/workflow-DRdwoDBT.css +1 -0
- package/dist/assets/workflow-dNPGY9xz.js +179 -0
- package/dist/cozyclay-package.json +1 -1
- package/dist/fonts/IBM-Plex-Sans-OFL.txt +92 -0
- package/dist/fonts/JetBrains-Mono-OFL.txt +93 -0
- package/dist/fonts/README.md +13 -9
- package/dist/fonts/ibm-plex-sans-400-latin.woff2 +0 -0
- package/dist/fonts/ibm-plex-sans-500-latin.woff2 +0 -0
- package/dist/fonts/ibm-plex-sans-600-latin.woff2 +0 -0
- package/dist/fonts/jetbrains-mono-400-latin.woff2 +0 -0
- package/dist/fonts/jetbrains-mono-500-latin.woff2 +0 -0
- package/dist/index.html +7 -7
- package/dist/privacy/index.html +13 -8
- package/dist/sitemap.xml +6 -6
- package/dist/workflow/index.html +5 -5
- package/mcp/LIVE-PROTOCOL.md +1 -1
- package/mcp/live-hub.mjs +35 -93
- package/mcp/mesh-file.mjs +48 -0
- package/mcp/server.mjs +6 -77
- package/mcp/tool-handlers.mjs +224 -377
- package/package.json +2 -1
- package/src/App.jsx +1273 -9075
- package/src/analytics.js +393 -9
- package/src/app-context.js +211 -0
- package/src/app-stage.jsx +25 -24
- package/src/ardy/auto-fix-panel.css +108 -0
- package/src/ardy/collision-blockers.js +9 -3
- package/src/ardy/fix-collisions.js +10 -66
- package/src/ardy/ground.js +4 -4
- package/src/ardy/ik-drag.js +101 -0
- package/src/ardy/ik-key-json.js +43 -0
- package/src/ardy/ik.js +122 -76
- package/src/ardy/physics-panel.css +2 -0
- package/src/ardy/physics-panel.jsx +17 -5
- package/src/ardy/platform-fit-panel.css +64 -0
- package/src/ardy/platform-fit-panel.jsx +40 -0
- package/src/ardy/platform-fit.js +326 -0
- package/src/ardy/playback.js +166 -20
- package/src/ardy/range-pin.js +299 -0
- package/src/ardy/timeline-coordinates.js +26 -0
- package/src/ardy/timeline.css +1199 -0
- package/src/ardy/timeline.jsx +149 -41
- package/src/ardy/waypoints.js +2 -2
- package/src/asset-pane.css +462 -0
- package/src/asset-pane.jsx +461 -232
- package/src/command-bus.js +349 -0
- package/src/commands/ai.js +31 -0
- package/src/commands/cast.js +140 -0
- package/src/commands/elements/character.js +13 -0
- package/src/commands/elements/motion.js +14 -0
- package/src/commands/elements/object.js +22 -0
- package/src/commands/elements/scene.js +16 -0
- package/src/commands/elements/shot.js +9 -0
- package/src/commands/elements/stage.js +11 -0
- package/src/commands/elements.js +155 -0
- package/src/commands/export.js +20 -0
- package/src/commands/index.js +40 -0
- package/src/commands/motion.js +231 -0
- package/src/commands/objects.js +174 -0
- package/src/commands/project.js +53 -0
- package/src/commands/scene.js +81 -0
- package/src/commands/shared.js +19 -0
- package/src/commands/shot.js +103 -0
- package/src/commands/stage.js +17 -0
- package/src/commands/view.js +42 -0
- package/src/document-store.js +144 -0
- package/src/domains/cast.js +1007 -0
- package/src/domains/motion.js +3219 -0
- package/src/domains/objects.js +932 -0
- package/src/domains/scenes.js +817 -0
- package/src/domains/shots.js +404 -0
- package/src/domains/stage.js +93 -0
- package/src/dualview.jsx +113 -57
- package/src/facing-marks.js +3 -0
- package/src/first-success-guide.jsx +14 -14
- package/src/grid-view.js +18 -5
- package/src/hierarchy-model.js +24 -16
- package/src/hierarchy-panel.css +386 -0
- package/src/hierarchy-panel.jsx +150 -21
- package/src/{fal-motion-client.js → i2v-motion-client.js} +13 -13
- package/src/i2v-motion-studio.jsx +180 -0
- package/src/ik-camera.js +3 -0
- package/src/main.jsx +6 -0
- package/src/motion/generation.js +105 -0
- package/src/motion-readiness-ui.jsx +4 -4
- package/src/motion-readiness.js +11 -0
- package/src/motion-trail.js +366 -9
- package/src/object-gizmo.jsx +7 -1
- package/src/otio.js +2 -1
- package/src/panels/CameraPanel.jsx +60 -0
- package/src/panels/CharacterTransformPanel.jsx +48 -0
- package/src/panels/EnvironmentPanel.jsx +40 -0
- package/src/panels/Foldout.jsx +32 -0
- package/src/panels/LightPanel.jsx +24 -0
- package/src/panels/ObjectTransformPanel.jsx +554 -0
- package/src/panels/PosePanel.jsx +97 -0
- package/src/panels/ProjectPanel.jsx +33 -0
- package/src/panels/PromptBlocksPanel.jsx +442 -0
- package/src/panels/PropsPanel.jsx +70 -0
- package/src/panels/ReferenceImageField.jsx +91 -0
- package/src/panels/RigControlPanel.jsx +78 -0
- package/src/panels/RigPanel.jsx +37 -0
- package/src/panels/SubjectBox.jsx +47 -0
- package/src/panels/SubjectsPanel.jsx +39 -0
- package/src/panels/VideoCapturePanel.jsx +180 -0
- package/src/panels/details.css +1171 -0
- package/src/panels/motion.css +197 -0
- package/src/panels/pose.css +39 -0
- package/src/planview.jsx +60 -31
- package/src/posestudio.jsx +59 -4
- package/src/project-browser.css +1073 -0
- package/src/project-browser.jsx +284 -123
- package/src/range-pin-object-transform.js +19 -0
- package/src/range-pin-panel.css +518 -0
- package/src/range-pin-panel.jsx +344 -0
- package/src/result-modal.jsx +5 -5
- package/src/room.jsx +79 -51
- package/src/scene-objects.js +37 -1
- package/src/scenes.js +5 -0
- package/src/semantic-edit.js +2 -0
- package/src/settings-menu.jsx +39 -105
- package/src/shell/BottomDock.jsx +450 -0
- package/src/shell/DetailsSlot.jsx +513 -0
- package/src/shell/LibrarySlot.jsx +86 -0
- package/src/shell/MenuBar.jsx +601 -0
- package/src/shell/OutlinerSlot.jsx +50 -0
- package/src/shell/PreferencesDialog.jsx +538 -0
- package/src/shell/PreferencesSlot.jsx +40 -0
- package/src/shell/StatusBar.jsx +125 -0
- package/src/shell/StudioShell.jsx +92 -0
- package/src/shell/TopBar.jsx +129 -0
- package/src/shell/ViewportToolbar.jsx +656 -0
- package/src/shell/agent-glass.css +296 -0
- package/src/shell/dock.css +93 -0
- package/src/shell/glass-regions.css +985 -0
- package/src/shell/glass.css +687 -0
- package/src/shell/log-store.js +52 -0
- package/src/shell/mode.css +9 -0
- package/src/shell/preferences.css +651 -0
- package/src/shell/shell.css +282 -0
- package/src/shell/studio-shell-context.js +19 -0
- package/src/shell/topbar.css +435 -0
- package/src/shell/viewport.css +451 -0
- package/src/store/authored-intent.js +22 -0
- package/src/store/runtime-adapters.js +92 -0
- package/src/store/scene-stage.js +21 -0
- package/src/store/use-document-store.js +14 -0
- package/src/studio-actions.js +210 -0
- package/src/studio-agent-commands.js +41 -271
- package/src/studio-agent-context.js +39 -10
- package/src/studio-agent-motion.js +122 -373
- package/src/studio-agent-protocol.js +67 -31
- package/src/studio-app-binding.js +379 -0
- package/src/studio-contact-sheet.js +73 -0
- package/src/studio-elements.js +58 -51
- package/src/styles/themes.css +200 -0
- package/src/styles/tokens.css +69 -0
- package/src/styles.css +460 -1742
- package/src/theme.js +44 -0
- package/src/timeline-extent.js +16 -0
- package/src/trail-key-conflicts.js +39 -0
- package/src/trail-pick.js +59 -0
- package/src/ui.jsx +8 -8
- package/src/use-case-question.jsx +66 -0
- package/src/workflow/AgentPanel.jsx +82 -69
- package/src/workflow/agent-client.js +12 -2
- package/src/workflow/agent-panel.css +34 -32
- package/src/workflow/cozy-scene-node.css +2 -0
- package/src/workflow/workflow.css +2 -0
- package/tools/ardy/__pycache__/cclay_gvhmr_worker.cpython-313.pyc +0 -0
- package/tools/ardy/bridge.mjs +164 -146
- package/tools/ardy/visual-qa.mjs +5 -5
- package/tools/bench/EXP3.md +61 -0
- package/tools/bench/cclay_bench_extract_incam.py +125 -0
- package/tools/bench/cclay_bench_extract_obs.py +204 -0
- package/tools/bench/cclay_bench_runner.py +42 -0
- package/tools/bench/cube-contact.mjs +162 -0
- package/tools/bench/exp3.mjs +152 -0
- package/tools/bench/extract-bench-lib.mjs +216 -0
- package/tools/bench/extract-bench.mjs +302 -0
- package/tools/bench/fal-generate.mjs +88 -0
- package/tools/bench/fit/README.md +189 -0
- package/tools/bench/fit/camera.mjs +59 -0
- package/tools/bench/fit/contact.mjs +419 -0
- package/tools/bench/fit/footlock.mjs +234 -0
- package/tools/bench/fit/motion.mjs +85 -0
- package/tools/bench/fit/pin.mjs +27 -0
- package/tools/bench/fit/remote.mjs +105 -0
- package/tools/bench/fit-bench.mjs +126 -0
- package/tools/bench/fit-sanity.mjs +45 -0
- package/tools/bench/metrics.mjs +313 -0
- package/tools/bench/obs/depth.mjs +258 -0
- package/tools/bench/obs/extrinsics.mjs +175 -0
- package/tools/bench/obs/fit_mannequin_betas.py +340 -0
- package/tools/bench/obs/ground.mjs +294 -0
- package/tools/bench/obs/heading.mjs +151 -0
- package/tools/bench/obs/ladder.mjs +555 -0
- package/tools/bench/obs/mannequin-betas.json +124 -0
- package/tools/bench/obs/remote.mjs +83 -0
- package/tools/bench/obs/rest_joints.py +52 -0
- package/tools/bench/obs/ybot-targets.mjs +49 -0
- package/tools/bench/obs-bench.mjs +520 -0
- package/tools/bench/score.mjs +343 -0
- package/tools/bench/summarize.mjs +86 -0
- package/tools/dev/pages/privacy.html +13 -8
- package/tools/gt-render/browser.mjs +159 -0
- package/tools/gt-render/camera-math.mjs +276 -0
- package/tools/gt-render/page.mjs +267 -0
- package/tools/gt-render/render.mjs +514 -0
- package/tools/gt-render/scene-box.mjs +31 -0
- package/tools/gt-render/take-transform.mjs +87 -0
- package/tools/morphgs/assets/gen_truth.py +39 -0
- package/tools/morphgs/assets/mesh_ori_rig.txt +27 -0
- package/tools/morphgs/assets/playback-check.mjs +30 -0
- package/tools/morphgs/demo-gate.sh +26 -0
- package/tools/morphgs/fbx2morphgs.mjs +68 -0
- package/tools/morphgs/morphgs-to-cskel27.mjs +105 -0
- package/tools/morphgs/patches/preprocess_src-none-mode.patch +76 -0
- package/tools/morphgs/setup-on-cluster.sh +126 -0
- package/tools/qa/css-rule-usage.mjs +283 -0
- package/tools/qa/studio-control-count.mjs +70 -32
- package/tools/run-tests.mjs +134 -12
- package/tools/track/DESIGN.md +513 -0
- package/tools/track/backfill-provenance.mjs +116 -0
- package/tools/track/budget.mjs +8 -0
- package/tools/track/check-rig.mjs +209 -0
- package/tools/track/diagnostics.schema.json +60 -0
- package/tools/track/export-rig.mjs +256 -0
- package/tools/track/fallback.mjs +7 -0
- package/tools/track/fk-parity-fixture.mjs +161 -0
- package/tools/track/gate.mjs +349 -0
- package/tools/track/masks.mjs +318 -0
- package/tools/track/metrics.mjs +201 -0
- package/tools/track/publish-obs.mjs +108 -0
- package/tools/track/py/check_env.py +61 -0
- package/tools/track/py/eval_lr.py +229 -0
- package/tools/track/py/lr_viterbi.py +294 -0
- package/tools/track/py/masks.py +405 -0
- package/tools/track/py/objective.py +382 -0
- package/tools/track/py/rig.py +508 -0
- package/tools/track/py/scene.py +326 -0
- package/tools/track/py/test_joint_indices.py +123 -0
- package/tools/track/py/test_lr_viterbi.py +195 -0
- package/tools/track/py/test_masks.py +229 -0
- package/tools/track/py/test_rig.py +288 -0
- package/tools/track/py/test_scene.py +354 -0
- package/tools/track/py/test_track.py +328 -0
- package/tools/track/py/track.py +411 -0
- package/tools/track/remote.mjs +140 -0
- package/tools/track/rig-dump.mjs +227 -0
- package/tools/track/run-box-tests.mjs +14 -0
- package/tools/track/run-box.mjs +168 -0
- package/tools/track/setup-box.sh +59 -0
- package/tools/track/study-2d.mjs +728 -0
- package/dist/assets/analytics-B1hnH66c.js +0 -1
- package/dist/assets/app-BWusbqgO.js +0 -4861
- package/dist/assets/app-qKDo4PBX.css +0 -1
- package/dist/assets/shot-prompt-CHUtw6af.js +0 -17
- package/dist/assets/shot-prompt-C_g2BHVc.css +0 -1
- package/dist/assets/workflow-CVwzMhz2.js +0 -179
- package/dist/assets/workflow-DsudxKHF.css +0 -1
- package/src/fal-motion-studio.jsx +0 -180
- package/src/scene-history.js +0 -129
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Reproducible issue #454 experiment driver. GPU and CDP work are serial. */
|
|
3
|
+
import { execFileSync } from "node:child_process";
|
|
4
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { basename, join, resolve } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { parseArgs } from "node:util";
|
|
8
|
+
import { backgroundDifferenceMask, deriveBox, drawProjectedBox, paletteMask, PALETTE_THRESHOLDS } from "./cube-contact.mjs";
|
|
9
|
+
import { assertGpuIdle } from "./fit/remote.mjs";
|
|
10
|
+
import { maskIoU, mean, meanJointError } from "./metrics.mjs";
|
|
11
|
+
|
|
12
|
+
const ROOT = fileURLToPath(new URL("../../", import.meta.url));
|
|
13
|
+
const SCENARIOS = ["bump", "handon", "sit", "stepup"];
|
|
14
|
+
const VARIANTS = ["shaded", "skin"];
|
|
15
|
+
const baseCondition = variant => variant === "skin" ? "yolo-vitpose" : "prod";
|
|
16
|
+
const json = path => JSON.parse(readFileSync(path, "utf8"));
|
|
17
|
+
const put = (path, value) => { mkdirSync(resolve(path, ".."), { recursive: true }); writeFileSync(path, JSON.stringify(value, null, 2) + "\n"); };
|
|
18
|
+
const ff = args => execFileSync("ffmpeg", ["-v", "error", "-y", ...args], { maxBuffer: 512 * 1024 * 1024 });
|
|
19
|
+
const run = (tool, args) => execFileSync(process.execPath, [join(ROOT, "tools", tool), ...args], { cwd: ROOT, stdio: "inherit" });
|
|
20
|
+
const aabb = info => ({ min: info.scene.min, max: info.scene.max });
|
|
21
|
+
function verticesAt(dir) {
|
|
22
|
+
const meta = json(join(dir, "vertices.json")), data = readFileSync(join(dir, "vertices.f32"));
|
|
23
|
+
if (data.length !== meta.frames * meta.vertexCount * 12) throw new Error("incomplete vertices.f32");
|
|
24
|
+
const floats = new Float32Array(data.buffer, data.byteOffset, data.length / 4);
|
|
25
|
+
return frame => floats.subarray(frame * meta.vertexCount * 3, (frame + 1) * meta.vertexCount * 3);
|
|
26
|
+
}
|
|
27
|
+
function contactSheet(dir, info, variant) {
|
|
28
|
+
const camera = json(join(dir, variant, "camera.json")), meta = json(join(dir, variant, "meta.json"));
|
|
29
|
+
const frames = [...new Set([0, info.contactFrames[0], info.witness.frame, meta.frames - 1])];
|
|
30
|
+
const images = frames.map(frame => {
|
|
31
|
+
const rgb = ff(["-i", join(dir, variant, "video.mp4"), "-vf", `select=eq(n\\,${frame})`, "-frames:v", "1", "-f", "rawvideo", "-pix_fmt", "rgb24", "pipe:1"]);
|
|
32
|
+
return drawProjectedBox(rgb, camera, info.box);
|
|
33
|
+
});
|
|
34
|
+
// Two columns, row-major; the corresponding frame numbers are recorded.
|
|
35
|
+
const png = execFileSync("ffmpeg", ["-v", "error", "-f", "rawvideo", "-pixel_format", "rgb24", "-video_size", `${camera.width}x${camera.height}`, "-i", "pipe:0", "-vf", `tile=2x${Math.ceil(images.length / 2)}`, "-frames:v", "1", "-f", "image2pipe", "-c:v", "png", "pipe:1"], { input: Buffer.concat(images), maxBuffer: 20 * 1024 * 1024 });
|
|
36
|
+
writeFileSync(join(dir, variant, "contact-sheet.png"), png);
|
|
37
|
+
put(join(dir, variant, "contact-sheet.json"), { frames, annotation: "Red: camera.json projections of all eight world-space cube corners and twelve edges." });
|
|
38
|
+
}
|
|
39
|
+
export function summarizeGt(root, names = SCENARIOS) {
|
|
40
|
+
const rows = [], missing = [];
|
|
41
|
+
for (const variant of VARIANTS) for (const name of names) for (let f = 0; f <= 5; f++) {
|
|
42
|
+
const dir = join(root, "gt-path/score", variant, name, `F${f}`), path = join(dir, "score.json");
|
|
43
|
+
if (!existsSync(path)) { missing.push(`${variant}/${name}/F${f}`); continue; }
|
|
44
|
+
const score = json(path), info = json(join(root, "gt", name, "scenario.json"));
|
|
45
|
+
const lines = readFileSync(join(dir, "frames.csv"), "utf8").trim().split("\n"), header = lines.shift().split(",");
|
|
46
|
+
const records = lines.map(line => Object.fromEntries(line.split(",").map((value, i) => [header[i], Number(value)])));
|
|
47
|
+
const contact = records.filter(r => info.contactFrames.includes(r.gt_frame));
|
|
48
|
+
const signed = contact.map(r => r.box_signed_pred_raw_m);
|
|
49
|
+
rows.push({ scenario: name, variant, baseCondition: baseCondition(variant), step: `F${f}`, contactFrames: contact.length, minDistanceM: signed.length ? Math.max(0, Math.min(...signed)) : null, maxPenetrationM: signed.length ? Math.max(0, -Math.min(...signed)) : null, mpjpeM: score.pose.mpjpeRootRelativeAlignedM, endpointM: score.endpoints.lastFrame.jointErrorAlignedM, iou: score.overlap.maskIoUAlignedMean });
|
|
50
|
+
}
|
|
51
|
+
const fmt = (n, scale = 1) => n === null ? "N/A" : (n * scale).toFixed(3);
|
|
52
|
+
const table = ["# Experiment 3: GT path", "", "Contact: RAW world placement, declared contact span only. MPJPE: aligned root-relative; endpoint: aligned last-frame mean joint error; IoU: aligned, cube-occluded character mask. Distances in cm. These metrics do not certify natural action.", "", "| Scenario | Variant | F | Contact frames | Min distance cm | Max penetration cm | MPJPE cm | Endpoint cm | Aligned IoU |", "|---|---|---|---:|---:|---:|---:|---:|---:|", ...rows.map(r => `| ${r.scenario} | ${r.variant} | ${r.step} | ${r.contactFrames} | ${fmt(r.minDistanceM, 100)} | ${fmt(r.maxPenetrationM, 100)} | ${fmt(r.mpjpeM, 100)} | ${fmt(r.endpointM, 100)} | ${fmt(r.iou)} |`), "", ...(missing.length ? [`Incomplete: ${missing.join(", ")}`, ""] : []), "F4 pins only native NPZ A/B endpoints. Studio rig retargeting/anchoring can still move them. F5 is skeletal collision handling, not skin contact optimization."];
|
|
53
|
+
mkdirSync(join(root, "gt-path"), { recursive: true }); writeFileSync(join(root, "gt-path/summary.md"), table.join("\n") + "\n"); put(join(root, "gt-path/summary.json"), { rows, missing });
|
|
54
|
+
return rows;
|
|
55
|
+
}
|
|
56
|
+
async function renderGt(root, names, ports, variants) {
|
|
57
|
+
const logs = readdirSync(join(root, "gt-motions")).filter(n => /^gen-log.*\.json$/.test(n)).flatMap(n => json(join(root, "gt-motions", n)));
|
|
58
|
+
for (const name of names) {
|
|
59
|
+
const pre = join(root, "prepass", name), gt = join(root, "gt", name), source = join(root, "gt-motions", `${name}.npz`);
|
|
60
|
+
if (!existsSync(join(pre, "joints.json"))) run("gt-render/render.mjs", ["--out", join(root, "prepass"), "--no-video", "--export-vertices", "--azimuth", "30", "--elevation", "5", "--f-mm", "35", ...ports, source]);
|
|
61
|
+
const info = { ...deriveBox(name, json(join(pre, "joints.json")), verticesAt(pre)), prompt: logs.find(l => l.name === name)?.prompt };
|
|
62
|
+
put(join(gt, "scenario.json"), info); put(join(gt, "fit-scene.json"), { boxes: [aabb(info)] });
|
|
63
|
+
console.log(`${name}: ${JSON.stringify(info.box)}; ${info.warnings.join(" ")}`);
|
|
64
|
+
run("gt-render/render.mjs", ["--out", join(root, "gt"), "--variants", variants.join(","), "--keep-frames", "--scene-box", JSON.stringify(info.box), "--box", JSON.stringify(aabb(info)), "--azimuth", "30", "--elevation", "5", "--f-mm", "35", ...ports, source]);
|
|
65
|
+
for (const variant of variants) contactSheet(gt, info, variant);
|
|
66
|
+
const contact = json(join(gt, "contact.json")), selected = info.contactFrames.map(f => contact.frames[f]);
|
|
67
|
+
put(join(gt, "contact-baseline.json"), { contactFrames: info.contactFrames, minDistanceM: Math.min(...selected.map(f => f.minDistanceM)), maxDistanceM: Math.max(...selected.map(f => f.minDistanceM)), maxPenetrationM: Math.max(...selected.map(f => f.maxPenetrationM)), pass: selected.every(f => f.minDistanceM <= 0.03 && f.maxPenetrationM <= 0.02) });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async function gtPath(root, names, ports, host, variants) {
|
|
71
|
+
for (const variant of variants) {
|
|
72
|
+
const base = baseCondition(variant);
|
|
73
|
+
await assertGpuIdle(host);
|
|
74
|
+
run("bench/extract-bench.mjs", ["--input", join(root, "gt"), "--out", join(root, "gt-path/extract"), "--motions", names.join(","), "--variants", variant, "--conditions", `${base},${base}+fmm`, "--host", host]);
|
|
75
|
+
for (const name of names) {
|
|
76
|
+
const gt = join(root, "gt", name), info = json(join(gt, "scenario.json"));
|
|
77
|
+
run("bench/fit-bench.mjs", ["--input", join(root, "gt"), "--extract", join(root, "gt-path/extract"), "--poses", join(root, "gt-motions"), "--out", join(root, "gt-path/fit", variant), "--variant", variant, "--base-condition", base, "--motions", name, "--host", host, "--scene", join(gt, "fit-scene.json")]);
|
|
78
|
+
const score = (pred, out) => run("bench/score.mjs", ["--gt", join(gt, variant), "--pred", pred, "--out", out, "--box", JSON.stringify(aabb(info)), "--gt-npz", join(root, "gt-motions", `${name}.npz`), ...ports]);
|
|
79
|
+
const baseline = join(root, "gt-path/gt-self", variant, name);
|
|
80
|
+
if (!existsSync(join(baseline, "score.json"))) score(join(root, "gt-motions", `${name}.npz`), baseline);
|
|
81
|
+
for (let f = 0; f <= 5; f++) {
|
|
82
|
+
const out = join(root, "gt-path/score", variant, name, `F${f}`);
|
|
83
|
+
if (!existsSync(join(out, "score.json"))) score(join(root, "gt-path/fit", variant, name, `F${f}`, "motion.npz"), out);
|
|
84
|
+
summarizeGt(root, names);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function videoInfo(path) {
|
|
90
|
+
return JSON.parse(execFileSync("ffprobe", ["-v", "error", "-select_streams", "v:0", "-show_entries", "stream=width,height,nb_frames,r_frame_rate,duration", "-of", "json", path], { encoding: "utf8" })).streams[0];
|
|
91
|
+
}
|
|
92
|
+
export function makeQaVideo(source, prediction, output) {
|
|
93
|
+
ff(["-i", source, "-i", prediction, "-filter_complex", "[0:v]split=2[a][ao];[1:v]split=2[b][bo];[ao][bo]blend=all_mode=average[o];[a][b][o]hstack=inputs=3:shortest=1[v]", "-map", "[v]", "-an", "-c:v", "libx264", "-crf", "18", "-pix_fmt", "yuv420p", output]);
|
|
94
|
+
}
|
|
95
|
+
async function falPath(root, names, ports, host, key, dryRun, variants) {
|
|
96
|
+
for (const variant of variants) for (const name of names) run("bench/fal-generate.mjs", ["--scenario", join(root, "gt", name), "--variant", variant, "--out", join(root, "fal/clips"), ...(key ? ["--key", key] : []), ...(dryRun ? ["--dry-run"] : [])]);
|
|
97
|
+
const clips = readdirSync(join(root, "fal/clips")).filter(clip => names.some(name => variants.some(variant => clip.startsWith(`${name}-${variant}-`))) && existsSync(join(root, "fal/clips", clip, "video.mp4")));
|
|
98
|
+
const qa = join(root, "qa-pack"); mkdirSync(qa, { recursive: true });
|
|
99
|
+
const csv = join(qa, "ratings.csv");
|
|
100
|
+
// Never overwrite a person's completed ratings on a resumed sweep.
|
|
101
|
+
if (!existsSync(csv)) writeFileSync(csv, "clip,prompt_adherence_0_2,contact_natural_0_2,usable_without_fix_YN,notes\n");
|
|
102
|
+
for (const clip of clips) {
|
|
103
|
+
const record = json(join(root, "fal/clips", clip, "request.json"));
|
|
104
|
+
const variant = record.variant, base = baseCondition(variant);
|
|
105
|
+
const gt = record.scenario, name = basename(gt), info = json(join(gt, "scenario.json")), input = join(root, "fal/input", clip, variant), poses = join(root, "fal/poses");
|
|
106
|
+
mkdirSync(input, { recursive: true }); mkdirSync(poses, { recursive: true });
|
|
107
|
+
const video = join(root, "fal/clips", clip, "video.mp4"), probe = videoInfo(video), camera = json(join(gt, variant, "camera.json"));
|
|
108
|
+
if (Math.abs(probe.width / probe.height / (camera.width / camera.height) - 1) > 0.01) throw new Error(`${clip}: fal changed aspect ratio; cannot claim the GT camera`);
|
|
109
|
+
ff(["-i", video, "-vf", `scale=${camera.width}:${camera.height},fps=24`, "-c:v", "libx264", "-crf", "12", "-pix_fmt", "yuv420p", join(input, "video.mp4")]);
|
|
110
|
+
copyFileSync(join(gt, variant, "camera.json"), join(input, "camera.json")); copyFileSync(join(gt, variant, "scene.json"), join(input, "scene.json"));
|
|
111
|
+
put(join(input, "meta.json"), { source: { path: video }, normalization: "spatially scaled to A-still dimensions, 24fps; no temporal stretch", cameraAssumption: "H3 obeyed the locked-camera prompt; drift is not corrected" });
|
|
112
|
+
copyFileSync(join(root, "gt-motions", `${name}.npz`), join(poses, `${clip}.npz`));
|
|
113
|
+
await assertGpuIdle(host);
|
|
114
|
+
// F0 needs the unknown-focal production baseline as well as the requested known-focal F1.
|
|
115
|
+
run("bench/extract-bench.mjs", ["--input", join(root, "fal/input"), "--out", join(root, "fal/extract"), "--motions", clip, "--variants", variant, "--conditions", `${base},${base}+fmm`, "--host", host]);
|
|
116
|
+
run("bench/fit-bench.mjs", ["--input", join(root, "fal/input"), "--extract", join(root, "fal/extract"), "--poses", poses, "--out", join(root, "fal/fit"), "--variant", variant, "--base-condition", base, "--motions", clip, "--host", host, "--scene", join(gt, "fit-scene.json")]);
|
|
117
|
+
const normalized = join(input, "video.mp4"), frames = Number(videoInfo(normalized).nb_frames), size = camera.width * camera.height;
|
|
118
|
+
const rgb = ff(["-i", normalized, "-f", "rawvideo", "-pix_fmt", "rgb24", "pipe:1"]);
|
|
119
|
+
const plate = variant === "skin" ? ff(["-i", join(gt, "plate.png"), "-f", "rawvideo", "-pix_fmt", "rgb24", "pipe:1"]) : null;
|
|
120
|
+
const masks = plate ? backgroundDifferenceMask(rgb, plate) : paletteMask(rgb);
|
|
121
|
+
const segmentation = plate ? { method: "background-difference", minChannelDifference: 30, plate: join(gt, "plate.png"), caveat: "Includes changed shadows/lighting/background; not semantic segmentation." } : { method: "palette-colour", ...PALETTE_THRESHOLDS };
|
|
122
|
+
const endpoints = json(join(gt, variant, "joints.json")), scores = [];
|
|
123
|
+
for (let f = 0; f <= 5; f++) {
|
|
124
|
+
const out = join(root, "fal/score", clip, `F${f}`), motion = join(root, "fal/fit", clip, `F${f}`, "motion.npz");
|
|
125
|
+
run("gt-render/render.mjs", ["--out", out, ...(f === 5 ? ["--variants", variant] : ["--no-video"]), "--camera", join(input, "camera.json"), "--scene-box", JSON.stringify(info.box), "--box", JSON.stringify(aabb(info)), ...ports, motion]);
|
|
126
|
+
const rendered = join(out, "motion"), joints = json(join(rendered, ...(f === 5 ? [variant] : []), "joints.json")), contact = json(join(rendered, "contact.json"));
|
|
127
|
+
const predMask = ff(["-i", join(rendered, "mask/%06d.png"), "-f", "rawvideo", "-pix_fmt", "gray", "pipe:1"]);
|
|
128
|
+
const count = Math.min(frames, joints.frames), ious = Array.from({ length: count }, (_, i) => maskIoU(masks.subarray(i * size, (i + 1) * size), predMask.subarray(i * size, (i + 1) * size)).iou);
|
|
129
|
+
const score = { clip, variant, baseCondition: base, step: `F${f}`, noMotionGroundTruth: true, mpjpe: null, endpointFirstM: meanJointError(joints.world[0], endpoints.world[0]), endpointLastM: meanJointError(joints.world.at(-1), endpoints.world.at(-1)), minDistanceM: Math.min(...contact.frames.map(v => v.minDistanceM)), maxPenetrationM: Math.max(...contact.frames.map(v => v.maxPenetrationM)), contactWindow: "entire clip: fal contact timing is unknown", overlapIoU: mean(ious), segmentation, comparedFrames: count, sourceFrames: frames, predictionFrames: joints.frames, alignment: "none; fixed A-still camera", cameraAssumption: "no H3 camera drift" };
|
|
130
|
+
put(join(out, "score.json"), score); scores.push(score);
|
|
131
|
+
if (f === 5) makeQaVideo(normalized, join(rendered, variant, "video.mp4"), join(qa, `${clip}.mp4`));
|
|
132
|
+
}
|
|
133
|
+
put(join(root, "fal/score", clip, "summary.json"), scores);
|
|
134
|
+
if (!readFileSync(csv, "utf8").split("\n").some(line => line.startsWith(`${clip},`))) writeFileSync(csv, `${clip},,,,\n`, { flag: "a" });
|
|
135
|
+
}
|
|
136
|
+
const scores = clips.flatMap(clip => { const path = join(root, "fal/score", clip, "summary.json"); return existsSync(path) ? json(path) : []; });
|
|
137
|
+
writeFileSync(join(root, "fal/summary.md"), ["# Experiment 3: fal path", "", "No intermediate motion GT. Endpoints are world mean joint error versus A/B; box metrics are whole-clip skin measurements; IoU is unaligned palette-colour (shaded) or empty-plate background-difference (skin) proxy overlap. Distances in cm.", "", "| Clip | Variant | F | A error | B error | Min distance | Max penetration | IoU |", "|---|---|---|---:|---:|---:|---:|---:|", ...scores.map(s => `| ${s.clip} | ${s.variant} | ${s.step} | ${(s.endpointFirstM * 100).toFixed(3)} | ${(s.endpointLastM * 100).toFixed(3)} | ${(s.minDistanceM * 100).toFixed(3)} | ${(s.maxPenetrationM * 100).toFixed(3)} | ${s.overlapIoU.toFixed(3)} |`), "", ...(!clips.length ? ["Pending live generation: no fal video available. Dry-run requests are not measurements."] : [])].join("\n") + "\n");
|
|
138
|
+
put(join(root, "fal/status.json"), { generatedClips: clips, pending: clips.length < names.length * variants.length * 3, plannedClips: names.length * variants.length * 3, variants, qa, note: clips.length ? "Only available metrics; no intermediate motion GT for fal." : "No live fal clips. Request dry-runs and mock-fetch tests do not validate the service or motion quality." });
|
|
139
|
+
}
|
|
140
|
+
export async function main(argv = process.argv.slice(2)) {
|
|
141
|
+
const { values: v } = parseArgs({ args: argv, options: { root: { type: "string" }, stage: { type: "string", default: "all" }, motions: { type: "string", default: SCENARIOS.join(",") }, variants: { type: "string", default: VARIANTS.join(",") }, host: { type: "string", default: "yun@ubuntu-baremetal" }, port: { type: "string", default: "5194" }, "cdp-port": { type: "string", default: "9234" }, key: { type: "string" }, "dry-run": { type: "boolean" }, help: { type: "boolean" } } });
|
|
142
|
+
if (v.help) { console.log("usage: node tools/bench/exp3.mjs --root <evidence/exp3> --stage gt|gt-path|fal|summary|all [--motions bump,handon,sit,stepup] [--variants shaded,skin] [--host yun@ubuntu-baremetal] [--port 5194 --cdp-port 9234] [--key <file>] [--dry-run]\nGT stage consumes gt-motions/*.npz; saves prepass, derived boxes, shaded renders and projected contact sheets. --dry-run affects fal generation only."); return; }
|
|
143
|
+
if (!v.root || !["gt", "gt-path", "fal", "summary", "all"].includes(v.stage)) throw new Error("--root and a valid --stage required");
|
|
144
|
+
const root = resolve(v.root), names = v.motions.split(","), variants = v.variants.split(","), ports = ["--port", v.port, "--cdp-port", v["cdp-port"]];
|
|
145
|
+
if (!names.every(n => SCENARIOS.includes(n))) throw new Error("unknown scenario");
|
|
146
|
+
if (!variants.every(variant => VARIANTS.includes(variant))) throw new Error("unknown variant");
|
|
147
|
+
if (["gt", "all"].includes(v.stage)) await renderGt(root, names, ports, variants);
|
|
148
|
+
if (["gt-path", "all"].includes(v.stage)) await gtPath(root, names, ports, v.host, variants);
|
|
149
|
+
if (["summary", "gt-path", "all"].includes(v.stage)) summarizeGt(root, names);
|
|
150
|
+
if (["fal", "all"].includes(v.stage)) await falPath(root, names, ports, v.host, v.key, v["dry-run"], variants);
|
|
151
|
+
}
|
|
152
|
+
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main().catch(e => { console.error(e.stack); process.exitCode = 1; });
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* extract-bench-lib.mjs — the pure half of tools/bench/extract-bench.mjs
|
|
3
|
+
* (#430): argument parsing, condition -> runner flag mapping, the production
|
|
4
|
+
* extraction defaults read from the same environment variables
|
|
5
|
+
* tools/ardy/extract.mjs reads, and runner-log parsing. No I/O here, so every
|
|
6
|
+
* decision the bench makes about WHAT it runs is unit-testable without a box.
|
|
7
|
+
*/
|
|
8
|
+
import { GVHMR_SMOOTH_SIGMA, gvhmrDetectorFromEnv, gvhmrKeypointsFromEnv, gvhmrRunnerArgs } from "../ardy/runners/gvhmr-worker.mjs";
|
|
9
|
+
|
|
10
|
+
// `path` is how the box is driven:
|
|
11
|
+
// worker the bridge's persistent worker (gvhmrWorker), exactly as
|
|
12
|
+
// handleExtract drives it — fast path + trajectory correction on.
|
|
13
|
+
// direct one `cclay_gvhmr_extract.py` process per run, the runner alone.
|
|
14
|
+
// prod follows production's own switch (CCLAY_GVHMR_WORKER=0 -> direct).
|
|
15
|
+
// The persistent worker hard-codes the palette detector, so any YOLO
|
|
16
|
+
// condition can only run direct.
|
|
17
|
+
export const CONDITIONS = Object.freeze({
|
|
18
|
+
prod: Object.freeze({ path: "worker", detector: "palette", keypoints: null }),
|
|
19
|
+
"palette-hybrid": Object.freeze({ path: "direct", detector: "palette", keypoints: "hybrid" }),
|
|
20
|
+
"palette-vitpose": Object.freeze({ path: "direct", detector: "palette", keypoints: "vitpose" }),
|
|
21
|
+
"yolo-vitpose": Object.freeze({ path: "direct", detector: "yolo", keypoints: "vitpose" }),
|
|
22
|
+
});
|
|
23
|
+
export const FMM_SUFFIX = "+fmm";
|
|
24
|
+
export const DEFAULT_CONDITIONS = Object.freeze(Object.keys(CONDITIONS));
|
|
25
|
+
export const DEFAULT_VARIANTS = Object.freeze(["shaded"]);
|
|
26
|
+
|
|
27
|
+
export const USAGE = `usage: node tools/bench/extract-bench.mjs --input <t1-root> --out <dir> [options]
|
|
28
|
+
|
|
29
|
+
--input <dir> T1 output root: <dir>/<motion>/<variant>/{video.mp4,camera.json}
|
|
30
|
+
--out <dir> results go to <dir>/<motion>/<variant>/<condition>/
|
|
31
|
+
--motions a,b motions to run (default: every <motion> dir under --input)
|
|
32
|
+
--variants a,b variants to run (default: ${DEFAULT_VARIANTS.join(",")})
|
|
33
|
+
--conditions a,b any of ${Object.keys(CONDITIONS).join(", ")},
|
|
34
|
+
each optionally suffixed ${FMM_SUFFIX} to pass camera.json gvhmrFMm
|
|
35
|
+
as --f-mm (default: ${DEFAULT_CONDITIONS.join(",")})
|
|
36
|
+
--host <ssh-dest> GPU box (default: CCLAY_EXTRACT_HOST, then CCLAY_ARDY_HOST)
|
|
37
|
+
--force re-run conditions whose result.json already says ok
|
|
38
|
+
--dry-run print the run plan (flags per run) and exit
|
|
39
|
+
--help this text
|
|
40
|
+
|
|
41
|
+
Runs are serial. Every motion x variant x condition writes motion.npz
|
|
42
|
+
(cskel27, production post-processing), gvhmr.npz (runner output), log.txt
|
|
43
|
+
and result.json.`;
|
|
44
|
+
|
|
45
|
+
function splitList(value, flag) {
|
|
46
|
+
const items = value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
47
|
+
if (!items.length) throw new Error(`${flag} needs at least one entry`);
|
|
48
|
+
return items;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** "prod+fmm" -> { name, base: "prod", fmm: true }; throws on unknown names. */
|
|
52
|
+
export function parseCondition(name) {
|
|
53
|
+
const fmm = name.endsWith(FMM_SUFFIX);
|
|
54
|
+
const base = fmm ? name.slice(0, -FMM_SUFFIX.length) : name;
|
|
55
|
+
if (!Object.hasOwn(CONDITIONS, base)) {
|
|
56
|
+
throw new Error(`unknown condition "${name}" (known: ${Object.keys(CONDITIONS).join(", ")}, each optionally ${FMM_SUFFIX})`);
|
|
57
|
+
}
|
|
58
|
+
return { name, base, fmm };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function parseArgs(argv, env = {}) {
|
|
62
|
+
const options = {
|
|
63
|
+
input: null,
|
|
64
|
+
out: null,
|
|
65
|
+
motions: null,
|
|
66
|
+
variants: [...DEFAULT_VARIANTS],
|
|
67
|
+
conditions: DEFAULT_CONDITIONS.map(parseCondition),
|
|
68
|
+
host: env.CCLAY_EXTRACT_HOST?.trim() || env.CCLAY_ARDY_HOST?.trim() || null,
|
|
69
|
+
force: false,
|
|
70
|
+
dryRun: false,
|
|
71
|
+
help: false,
|
|
72
|
+
};
|
|
73
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
74
|
+
const flag = argv[index];
|
|
75
|
+
const value = () => {
|
|
76
|
+
const next = argv[index + 1];
|
|
77
|
+
if (next === undefined || next.startsWith("--")) throw new Error(`${flag} needs a value`);
|
|
78
|
+
index += 1;
|
|
79
|
+
return next;
|
|
80
|
+
};
|
|
81
|
+
switch (flag) {
|
|
82
|
+
case "--input": options.input = value(); break;
|
|
83
|
+
case "--out": options.out = value(); break;
|
|
84
|
+
case "--motions": options.motions = splitList(value(), flag); break;
|
|
85
|
+
case "--variants": options.variants = splitList(value(), flag); break;
|
|
86
|
+
case "--conditions": {
|
|
87
|
+
const names = splitList(value(), flag);
|
|
88
|
+
options.conditions = [...new Set(names)].map(parseCondition);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case "--host": options.host = value(); break;
|
|
92
|
+
case "--force": options.force = true; break;
|
|
93
|
+
case "--dry-run": options.dryRun = true; break;
|
|
94
|
+
case "--help": case "-h": options.help = true; break;
|
|
95
|
+
default: throw new Error(`unknown argument: ${flag}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (options.help) return options;
|
|
99
|
+
if (!options.input) throw new Error("--input is required");
|
|
100
|
+
if (!options.out) throw new Error("--out is required");
|
|
101
|
+
if (!options.dryRun && !options.host) throw new Error("no GPU host: pass --host or set CCLAY_EXTRACT_HOST / CCLAY_ARDY_HOST");
|
|
102
|
+
return options;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The extraction defaults handleExtract reads at import time, read from the
|
|
107
|
+
* same variables with the same parsing, so the bench's prod condition and a
|
|
108
|
+
* bridge started in the same shell run the same take.
|
|
109
|
+
*/
|
|
110
|
+
export function productionExtractEnv(env = {}) {
|
|
111
|
+
return {
|
|
112
|
+
staticCam: (env.CCLAY_EXTRACT_STATIC_CAM?.trim() || "1") !== "0",
|
|
113
|
+
detector: gvhmrDetectorFromEnv(env),
|
|
114
|
+
keypoints: gvhmrKeypointsFromEnv(env),
|
|
115
|
+
worker: env.CCLAY_GVHMR_WORKER?.trim() !== "0",
|
|
116
|
+
trajectory: env.CCLAY_GVHMR_TRAJECTORY?.trim() !== "0",
|
|
117
|
+
smoothSigma: GVHMR_SMOOTH_SIGMA,
|
|
118
|
+
stabilize: {
|
|
119
|
+
enabled: env.CCLAY_GVHMR_SMOOTHING?.trim() !== "0",
|
|
120
|
+
smoothRotations: env.CCLAY_GVHMR_ROTATION_SMOOTHING?.trim() !== "0",
|
|
121
|
+
anchorFeet: env.CCLAY_GVHMR_ANCHOR_FEET?.trim() !== "0",
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Everything one run needs to know about its condition:
|
|
128
|
+
* path "worker" | "direct"
|
|
129
|
+
* runnerArgs flags for cclay_gvhmr_extract.py (direct path; for the
|
|
130
|
+
* worker path, the flags its runner_argv derives from the request)
|
|
131
|
+
* workerFields the request fields beside video/output/outRoot (worker path)
|
|
132
|
+
* stabilize stabilizeMotion options
|
|
133
|
+
* `cameraFMm` is camera.json's gvhmrFMm; required only for a +fmm condition.
|
|
134
|
+
*/
|
|
135
|
+
export function resolveCondition(condition, { cameraFMm = null, env = {} } = {}) {
|
|
136
|
+
const spec = typeof condition === "string" ? parseCondition(condition) : condition;
|
|
137
|
+
const base = CONDITIONS[spec.base];
|
|
138
|
+
const prod = productionExtractEnv(env);
|
|
139
|
+
let fMm = null;
|
|
140
|
+
if (spec.fmm) {
|
|
141
|
+
if (!Number.isFinite(cameraFMm) || cameraFMm <= 0) throw new Error(`${spec.name}: camera.json has no usable gvhmrFMm`);
|
|
142
|
+
fMm = Math.trunc(cameraFMm);
|
|
143
|
+
}
|
|
144
|
+
const detector = base.detector === "palette" ? prod.detector : base.detector;
|
|
145
|
+
const keypoints = base.keypoints ?? prod.keypoints;
|
|
146
|
+
const path = spec.base === "prod" && !prod.worker ? "direct" : base.path;
|
|
147
|
+
// Start from production's own flag builder so every flag the bench does
|
|
148
|
+
// not vary (static cam, smoothing sigma, f-mm formatting) is byte-for-byte
|
|
149
|
+
// production's; only a non-palette detector is swapped in afterwards,
|
|
150
|
+
// because gvhmrRunnerArgs deliberately refuses to emit one.
|
|
151
|
+
const runnerArgs = gvhmrRunnerArgs({ staticCam: prod.staticCam, fMm, detector, keypoints, smoothSigma: prod.smoothSigma });
|
|
152
|
+
if (detector !== "palette") runnerArgs[runnerArgs.indexOf("--detector") + 1] = detector;
|
|
153
|
+
// Same field order as handleExtract's request; fMm only when asked for,
|
|
154
|
+
// so a plain prod request is exactly the bridge's.
|
|
155
|
+
const workerFields = path === "worker"
|
|
156
|
+
? { staticCam: prod.staticCam, detector, keypoints, trajectory: prod.trajectory, smoothSigma: prod.smoothSigma, ...(fMm != null ? { fMm } : {}) }
|
|
157
|
+
: null;
|
|
158
|
+
return { name: spec.name, base: spec.base, fmm: spec.fmm, fMm, path, detector, keypoints, runnerArgs, workerFields, stabilize: prod.stabilize };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const ELAPSED = /^\[\+(\d+(?:\.\d+)?)s\] ?/;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Summarise a runner log (log.txt: optionally "[+12.34s] " elapsed prefixes,
|
|
165
|
+
* as the bench writes it). Detection counts come from:
|
|
166
|
+
* palette "[cclay] detector palette: N/M frames"
|
|
167
|
+
* yolo "[bench] yolo track: N/M frames" (bench launcher, tracker path)
|
|
168
|
+
* "[cclay] tracker failed; using raw detections on N/M frames"
|
|
169
|
+
* and apply only to the detector the runner finally selected.
|
|
170
|
+
*/
|
|
171
|
+
export function parseRunnerLog(text) {
|
|
172
|
+
const summary = {
|
|
173
|
+
detector: null, detectedFrames: null, totalFrames: null, detectionRate: null, detectionSource: null,
|
|
174
|
+
yoloConf: null, keypoints: null, videoFrames: null, videoFps: null, staticCam: null,
|
|
175
|
+
wroteFrames: null, rootTravelM: null, lrFlipFrames: [], hybridOverrides: null, stages: [],
|
|
176
|
+
};
|
|
177
|
+
let palette = null;
|
|
178
|
+
let yolo = null;
|
|
179
|
+
for (const raw of String(text).split(/[\r\n]+/)) {
|
|
180
|
+
const elapsed = ELAPSED.exec(raw);
|
|
181
|
+
const at = elapsed ? Number(elapsed[1]) : null;
|
|
182
|
+
const line = elapsed ? raw.slice(elapsed[0].length) : raw;
|
|
183
|
+
let m;
|
|
184
|
+
if ((m = /\[cclay\] stage (\w+)/.exec(line))) summary.stages.push({ stage: m[1], at });
|
|
185
|
+
else if ((m = /\[cclay\] detector palette: (\d+)\/(\d+) frames/.exec(line))) palette = { detected: +m[1], total: +m[2], source: "palette-log" };
|
|
186
|
+
else if ((m = /\[bench\] yolo track: (\d+)\/(\d+) frames/.exec(line))) yolo = { detected: +m[1], total: +m[2], source: "yolo-track" };
|
|
187
|
+
else if ((m = /\[cclay\] tracker failed; using raw detections on (\d+)\/(\d+) frames/.exec(line))) yolo = { detected: +m[1], total: +m[2], source: "yolo-raw-detections" };
|
|
188
|
+
else if ((m = /\[cclay\] person track found at yolo conf ([\d.]+)/.exec(line))) summary.yoloConf = Number(m[1]);
|
|
189
|
+
else if ((m = /\[cclay\] detector: (\w+) selected/.exec(line))) summary.detector = m[1];
|
|
190
|
+
else if ((m = /\[cclay\] keypoints: (\w+) selected/.exec(line))) summary.keypoints = m[1];
|
|
191
|
+
else if ((m = /\[cclay\] \S+ L=(\d+) \d+x\d+ @ ([\d.]+) fps static_cam=(\w+)/.exec(line))) {
|
|
192
|
+
summary.videoFrames = Number(m[1]);
|
|
193
|
+
summary.videoFps = Number(m[2]);
|
|
194
|
+
summary.staticCam = m[3] === "True";
|
|
195
|
+
} else if ((m = /\[cclay\] wrote \S+: (\d+) frames @ [\d.]+ fps, root XZ travel ([\d.]+) m/.exec(line))) {
|
|
196
|
+
summary.wroteFrames = Number(m[1]);
|
|
197
|
+
summary.rootTravelM = Number(m[2]);
|
|
198
|
+
} else if ((m = /\[cclay\] left\/right flip corrected at frames \[([\d, ]*)\]/.exec(line))) {
|
|
199
|
+
summary.lrFlipFrames.push(...m[1].split(",").map((v) => v.trim()).filter(Boolean).map(Number));
|
|
200
|
+
} else if ((m = /\[cclay\] keypoints hybrid: .*?; (\d+) joint observations/.exec(line))) summary.hybridOverrides = Number(m[1]);
|
|
201
|
+
}
|
|
202
|
+
const counted = summary.detector === "palette" ? palette : summary.detector === "yolo" ? yolo : null;
|
|
203
|
+
if (counted) {
|
|
204
|
+
summary.detectedFrames = counted.detected;
|
|
205
|
+
summary.totalFrames = counted.total;
|
|
206
|
+
summary.detectionRate = counted.total ? counted.detected / counted.total : null;
|
|
207
|
+
summary.detectionSource = counted.source;
|
|
208
|
+
}
|
|
209
|
+
// Wall time per stage: from its own line to the next stage line (the last
|
|
210
|
+
// stage has no successor and stays null).
|
|
211
|
+
summary.stages = summary.stages.map((entry, index, all) => ({
|
|
212
|
+
...entry,
|
|
213
|
+
seconds: entry.at != null && all[index + 1]?.at != null ? Number((all[index + 1].at - entry.at).toFixed(3)) : null,
|
|
214
|
+
}));
|
|
215
|
+
return summary;
|
|
216
|
+
}
|