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.

Body Double: sample files carry their version, so a replaced example shows at once

Adarsh5673a6e2bf27
diff --git a/src/components/body-double/body-double-tool.tsx b/src/components/body-double/body-double-tool.tsx
index 945cb638..60d2ee23 100644
--- a/src/components/body-double/body-double-tool.tsx
+++ b/src/components/body-double/body-double-tool.tsx
@@ -14,7 +14,7 @@ import { ModelViewer } from "@/components/studio/result-media";
import { RunPlaceChip, useOpenRunPlace } from "@/components/studio/run-place-chip";
import { askToSignUp, useAskBeforeUpload, useCreateGeneration, useGenerations, useIsGuest } from "@/lib/api";
import { getModel } from "@/lib/catalog";
-import { BODY_DOUBLE, BODY_DOUBLE_DEMOS, BODY_LOOKS, type BodyLookId, bodyDoubleRequest, bodyLook } from "@/lib/catalog/body-double";
+import { BODY_DOUBLE, BODY_DOUBLE_DEMOS, BODY_LOOKS, type BodyLookId, bodyDoubleRequest, bodyDoubleSample, bodyLook } from "@/lib/catalog/body-double";
import type { Generation, GenerationRequest, OutputFile } from "@/lib/catalog/types";
import { downloadHref } from "@/lib/library";
import { toastError } from "@/lib/refusals";
@@ -26,8 +26,8 @@ import { usePlayInView } from "./use-play-in-view";
type Mode = "live" | "photo" | "clip";
const SUBTITLE = "A 3D body for every person: live from your camera, from a photo, or from a clip as motion capture you can animate with.";
const EXAMPLES: Record<"photo" | "clip", { src: string; name: string; label: string }> = {
- photo: { src: "/samples/body-double/photo-before.jpg", name: "body-double-example.jpg", label: "Try it on this photo" },
- clip: { src: "/samples/body-double/sample-dance.mp4", name: "body-double-example.mp4", label: "Try it on this dance" },
+ photo: { src: bodyDoubleSample("photo-before.jpg"), name: "body-double-example.jpg", label: "Try it on this photo" },
+ clip: { src: bodyDoubleSample("sample-dance.mp4"), name: "body-double-example.mp4", label: "Try it on this dance" },
};
function AddMedia({ mode, onPick }: { mode: "photo" | "clip"; onPick: (v: SlotValue) => void }) {
diff --git a/src/components/body-double/live-view.tsx b/src/components/body-double/live-view.tsx
index f0265441..7adedf33 100644
--- a/src/components/body-double/live-view.tsx
+++ b/src/components/body-double/live-view.tsx
@@ -9,15 +9,15 @@ import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { type DrawBody, N_VERTS } from "@/lib/body-double/hmr";
import type { Outline } from "@/lib/body-double/outline";
-import { BODY_DOUBLE_DEMOS } from "@/lib/catalog/body-double";
+import { BODY_DOUBLE_DEMOS, bodyDoubleSample } from "@/lib/catalog/body-double";
import { usePlayInView } from "./use-play-in-view";
import { cn } from "@/lib/utils";
import type { LiveReply, LiveRequest } from "./hmr.worker";
/** A clip anyone can try Live on before turning on their camera. */
export const LIVE_SAMPLES = [
- { src: "/samples/body-double/sample-dance.mp4", label: "Gallery dance" },
- { src: "/samples/body-double/sample-runway.mp4", label: "Runway walk" },
+ { src: bodyDoubleSample("sample-dance.mp4"), label: "Gallery dance" },
+ { src: bodyDoubleSample("sample-runway.mp4"), label: "Runway walk" },
] as const;
diff --git a/src/components/home/body-double-showcase.tsx b/src/components/home/body-double-showcase.tsx
index 82b35657..d91334dc 100644
--- a/src/components/home/body-double-showcase.tsx
+++ b/src/components/home/body-double-showcase.tsx
@@ -2,12 +2,12 @@
import { useRef, useState } from "react";
import { usePlayInView } from "@/components/body-double/use-play-in-view";
-import { BODY_DOUBLE_DEMOS, BODY_LOOKS, type BodyLookId } from "@/lib/catalog/body-double";
+import { BODY_DOUBLE_DEMOS, BODY_LOOKS, type BodyLookId, bodyDoubleSample } from "@/lib/catalog/body-double";
import { cn } from "@/lib/utils";
type Shown = "motion" | BodyLookId;
-const lookSrc = (look: BodyLookId) => `/samples/body-double/looks/${look}.jpg`;
+const lookSrc = (look: BodyLookId) => bodyDoubleSample(`looks/${look}.jpg`);
/** Each look's picture fetched once, the first time its chip is pointed at, so it shows at once when picked. */
const warmed = new Set<string>();
const warm = (look: BodyLookId) => {
diff --git a/src/lib/catalog/body-double.ts b/src/lib/catalog/body-double.ts
index 6c3035a3..6e73c992 100644
--- a/src/lib/catalog/body-double.ts
+++ b/src/lib/catalog/body-double.ts
@@ -18,11 +18,38 @@ export const BODY_DOUBLE = {
maxClipSeconds: 15,
} as const;
+/**
+ * Each sample file's content version (the first 8 hex digits of its SHA-256), sent as ?v= so a replaced file reaches every
+ * browser and cache at once. tests/body-double.test.ts checks them against the files.
+ */
+export const BODY_DOUBLE_SAMPLE_VERSIONS: Readonly<Record<string, string>> = {
+ "photo-before.jpg": "56ca09c2",
+ "photo-after.jpg": "294e3e56",
+ "clip-demo.mp4": "43a09a50",
+ "clip-demo.jpg": "7e65670a",
+ "live-demo.mp4": "cf4d5064",
+ "live-demo.jpg": "659e563b",
+ "sample-dance.mp4": "227afd20",
+ "sample-runway.mp4": "037d4010",
+ "looks/clay.jpg": "888d7861",
+ "looks/ghost.jpg": "384abfcf",
+ "looks/holo.jpg": "0b529b89",
+ "looks/skeleton.jpg": "acad3f42",
+ "looks/thermal.jpg": "77c5d4cb",
+ "looks/xray.jpg": "46012531",
+};
+
+/** A Body Double sample's URL, with its version. */
+export const bodyDoubleSample = (file: string): string => {
+ const v = BODY_DOUBLE_SAMPLE_VERSIONS[file];
+ return v ? `/samples/body-double/${file}?v=${v}` : `/samples/body-double/${file}`;
+};
+
/** Finished examples shown on the app's page, each made the way a run makes it: a group photo before and after, a motion capture, and a Live session recorded in the browser. */
export const BODY_DOUBLE_DEMOS = {
- photo: { before: "/samples/body-double/photo-before.jpg", after: "/samples/body-double/photo-after.jpg" },
- clip: { video: "/samples/body-double/clip-demo.mp4", poster: "/samples/body-double/clip-demo.jpg" },
- live: { video: "/samples/body-double/live-demo.mp4", poster: "/samples/body-double/live-demo.jpg" },
+ photo: { before: bodyDoubleSample("photo-before.jpg"), after: bodyDoubleSample("photo-after.jpg") },
+ clip: { video: bodyDoubleSample("clip-demo.mp4"), poster: bodyDoubleSample("clip-demo.jpg") },
+ live: { video: bodyDoubleSample("live-demo.mp4"), poster: bodyDoubleSample("live-demo.jpg") },
} as const;
export type BodyLookId = "holo" | "clay" | "thermal" | "ghost" | "xray" | "skeleton";
diff --git a/tests/body-double.test.ts b/tests/body-double.test.ts
index 98a6f3ab..2aa5160c 100644
--- a/tests/body-double.test.ts
+++ b/tests/body-double.test.ts
@@ -154,3 +154,18 @@ describe("Body Double's graphs", () => {
}
});
});
+
+describe("Body Double samples", () => {
+ it("carry the version of the file they point at, so a replaced sample reaches every browser", async () => {
+ const { createHash } = await import("node:crypto");
+ const { BODY_DOUBLE_SAMPLE_VERSIONS, bodyDoubleSample } = await import("@/lib/catalog/body-double");
+ const dir = path.join(process.cwd(), "public/samples/body-double");
+ const files = [...fs.readdirSync(dir).filter((f) => /\.(mp4|jpg)$/.test(f)), ...fs.readdirSync(path.join(dir, "looks")).map((f) => `looks/${f}`)];
+ expect(Object.keys(BODY_DOUBLE_SAMPLE_VERSIONS).sort()).toEqual(files.sort());
+ for (const f of files) {
+ const v = createHash("sha256").update(fs.readFileSync(path.join(dir, f))).digest("hex").slice(0, 8);
+ expect(BODY_DOUBLE_SAMPLE_VERSIONS[f], f).toBe(v);
+ expect(bodyDoubleSample(f)).toBe(`/samples/body-double/${f}?v=${v}`);
+ }
+ });
+});