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.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Body Double: a group of four as its cover, finished examples, and Live that keeps up
Adarshf10dce9d9a4a
diff --git a/public/previews/body-double/clip-demo.jpg b/public/previews/body-double/clip-demo.jpgnew file mode 100644index 00000000..c56d24cfBinary files /dev/null and b/public/previews/body-double/clip-demo.jpg differdiff --git a/public/previews/body-double/clip-demo.mp4 b/public/previews/body-double/clip-demo.mp4new file mode 100644index 00000000..fa9b3692Binary files /dev/null and b/public/previews/body-double/clip-demo.mp4 differdiff --git a/public/previews/body-double/photo-after.jpg b/public/previews/body-double/photo-after.jpgnew file mode 100644index 00000000..214fdcbdBinary files /dev/null and b/public/previews/body-double/photo-after.jpg differdiff --git a/public/previews/body-double/photo-before.jpg b/public/previews/body-double/photo-before.jpgnew file mode 100644index 00000000..ab98a3adBinary files /dev/null and b/public/previews/body-double/photo-before.jpg differdiff --git a/public/previews/body-double/sample-dance.mp4 b/public/previews/body-double/sample-dance.mp4new file mode 100644index 00000000..39499172Binary files /dev/null and b/public/previews/body-double/sample-dance.mp4 differdiff --git a/public/previews/body-double/sample-runway.mp4 b/public/previews/body-double/sample-runway.mp4new file mode 100644index 00000000..7a43289cBinary files /dev/null and b/public/previews/body-double/sample-runway.mp4 differdiff --git a/public/previews/presets/app-body-double.jpg b/public/previews/presets/app-body-double.jpgindex 4d9c6af4..b347c1d1 100644Binary files a/public/previews/presets/app-body-double.jpg and b/public/previews/presets/app-body-double.jpg differdiff --git a/public/previews/presets/app-body-double.mp4 b/public/previews/presets/app-body-double.mp4index c28a5f9b..48e42d6f 100644Binary files a/public/previews/presets/app-body-double.mp4 and b/public/previews/presets/app-body-double.mp4 differdiff --git a/public/previews/presets/ba/1280/app-body-double-after.jpg b/public/previews/presets/ba/1280/app-body-double-after.jpgindex 72ef5119..1f5851df 100644Binary files a/public/previews/presets/ba/1280/app-body-double-after.jpg and b/public/previews/presets/ba/1280/app-body-double-after.jpg differdiff --git a/public/previews/presets/ba/1280/app-body-double-before.jpg b/public/previews/presets/ba/1280/app-body-double-before.jpgindex b00e0e58..b9e15f35 100644Binary files a/public/previews/presets/ba/1280/app-body-double-before.jpg and b/public/previews/presets/ba/1280/app-body-double-before.jpg differdiff --git a/public/previews/presets/ba/512/app-body-double-after.jpg b/public/previews/presets/ba/512/app-body-double-after.jpgindex c54755ef..76b1d436 100644Binary files a/public/previews/presets/ba/512/app-body-double-after.jpg and b/public/previews/presets/ba/512/app-body-double-after.jpg differdiff --git a/public/previews/presets/ba/512/app-body-double-before.jpg b/public/previews/presets/ba/512/app-body-double-before.jpgindex f7959008..b0e3b10e 100644Binary files a/public/previews/presets/ba/512/app-body-double-before.jpg and b/public/previews/presets/ba/512/app-body-double-before.jpg differdiff --git a/public/previews/presets/ba/960/app-body-double-after.jpg b/public/previews/presets/ba/960/app-body-double-after.jpgindex 869395bb..fe00c520 100644Binary files a/public/previews/presets/ba/960/app-body-double-after.jpg and b/public/previews/presets/ba/960/app-body-double-after.jpg differdiff --git a/public/previews/presets/ba/960/app-body-double-before.jpg b/public/previews/presets/ba/960/app-body-double-before.jpgindex 9fb304a2..876f9a75 100644Binary files a/public/previews/presets/ba/960/app-body-double-before.jpg and b/public/previews/presets/ba/960/app-body-double-before.jpg differdiff --git a/public/previews/presets/mini/app-body-double.jpg b/public/previews/presets/mini/app-body-double.jpgindex c77bdab3..0b29925d 100644Binary files a/public/previews/presets/mini/app-body-double.jpg and b/public/previews/presets/mini/app-body-double.jpg differdiff --git a/public/previews/presets/thumbs/app-body-double.jpg b/public/previews/presets/thumbs/app-body-double.jpgindex 426426d7..5bd51814 100644Binary files a/public/previews/presets/thumbs/app-body-double.jpg and b/public/previews/presets/thumbs/app-body-double.jpg differdiff --git a/src/components/body-double/body-double-tool.tsx b/src/components/body-double/body-double-tool.tsxindex 59562e1d..2449c857 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_LOOKS, type BodyLookId, bodyDoubleRequest, bodyLook } from "@/lib/catalog/body-double";+import { BODY_DOUBLE, BODY_DOUBLE_DEMOS, BODY_LOOKS, type BodyLookId, bodyDoubleRequest, 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";@@ -25,8 +25,8 @@ import { LiveView } from "./live-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: "/previews/presets/ba/1280/app-outfit-shot-after.jpg", name: "body-double-example.jpg", label: "Try it on this photo" },- clip: { src: "/previews/presets/app-dance.mp4", name: "body-double-example.mp4", label: "Try it on this dance" },+ photo: { src: "/previews/body-double/photo-before.jpg", name: "body-double-example.jpg", label: "Try it on this photo" },+ clip: { src: "/previews/body-double/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 }) {@@ -230,8 +230,9 @@ export function BodyDoubleTool({ app }: { app: { name: string; description: stri{mode === "live" ? (<LiveView />) : !media ? (- <div className="mx-auto max-w-[640px]">+ <div className="grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)] lg:items-start"><AddMedia key={mode} mode={mode} onPick={take} />+ <Demo mode={mode} /></div>) : (<div className="grid gap-3 lg:grid-cols-[minmax(0,1fr)_340px] lg:items-start">@@ -288,6 +289,33 @@ export function BodyDoubleTool({ app }: { app: { name: string; description: stri);}+/** A finished example of the mode: what a run gives back. */+function Demo({ mode }: { mode: "photo" | "clip" }) {+ const [after, setAfter] = useState(true);+ if (mode === "clip") {+ const d = BODY_DOUBLE_DEMOS.clip;+ return (+ <figure className="space-y-2 rounded-2xl border bg-background p-2.5 shadow-soft">+ <video src={d.video} poster={d.poster} autoPlay muted loop playsInline className="block w-full rounded-xl bg-media" />+ <figcaption className="px-0.5 text-[12px] text-muted-foreground">A dance in, its motion capture out: the body over every frame, the pose, and an animated 3D body.</figcaption>+ </figure>+ );+ }+ const d = BODY_DOUBLE_DEMOS.photo;+ return (+ <figure className="space-y-2 rounded-2xl border bg-background p-2.5 shadow-soft">+ <button type="button" aria-pressed={after} onClick={() => setAfter((a) => !a)} className="relative block w-full overflow-hidden rounded-xl bg-media outline-none focus-visible:ring-2 focus-visible:ring-ring">+ {/* eslint-disable-next-line @next/next/no-img-element */}+ <img src={d.before} alt="Four models on a rooftop runway" className="block w-full" draggable={false} />+ {/* eslint-disable-next-line @next/next/no-img-element */}+ <img src={d.after} alt="Each of the four with their 3D body" className={cn("absolute inset-0 size-full transition-opacity duration-300", after ? "opacity-100" : "opacity-0")} draggable={false} />+ <span className="pointer-events-none absolute top-2 left-2 rounded-full bg-black/55 px-2 py-0.5 text-[11px] font-medium text-white backdrop-blur">{after ? "Body Double" : "Photo"}</span>+ </button>+ <figcaption className="px-0.5 text-[12px] text-muted-foreground">Every person in the shot gets a body. Tap the picture to compare.</figcaption>+ </figure>+ );+}+type View = "over" | "3d" | "pose";/** One run: the body over the input, the 3D body and the pose, with their downloads. */diff --git a/src/components/body-double/live-view.tsx b/src/components/body-double/live-view.tsxindex 96002262..3782c56f 100644--- a/src/components/body-double/live-view.tsx+++ b/src/components/body-double/live-view.tsx@@ -8,16 +8,15 @@ import { RoomEnvironment } from "three/examples/jsm/environments/RoomEnvironmentimport { toast } from "sonner";import { Button } from "@/components/ui/button";import { createHmr, type Hmr, N_VERTS } from "@/lib/body-double/hmr";+import { BODY_DOUBLE_DEMOS } from "@/lib/catalog/body-double";import { cn } from "@/lib/utils";/** A clip anyone can try Live on before turning on their camera. */export const LIVE_SAMPLES = [- { src: "/previews/presets/app-dance.mp4", label: "Ballroom dance" },- { src: "/previews/presets/motion-catwalk.mp4", label: "Runway walk" },+ { src: "/previews/body-double/sample-dance.mp4", label: "Gallery dance" },+ { src: "/previews/body-double/sample-runway.mp4", label: "Runway walk" },] as const;-/** A finished Body Double, played on the stage until Live starts. */-const LIVE_PREVIEW = "/previews/presets/app-body-double.mp4";export type LiveLook = "chrome" | "iris" | "holo" | "wire";export const LIVE_LOOKS: { value: LiveLook; label: string }[] = [@@ -181,6 +180,9 @@ export function LiveView() {const stageRef = useRef<HTMLDivElement>(null);const videoRef = useRef<HTMLVideoElement>(null);const overlayRef = useRef<HTMLCanvasElement>(null);+ /** The frame each body was found in, shown under it so the two always match (the video plays on, out of sight). */+ const frameRef = useRef<HTMLCanvasElement>(null);+ const grab = useRef<HTMLCanvasElement | null>(null);const orbitRef = useRef<HTMLCanvasElement>(null);const scenes = useRef<Scenes | null>(null);const hmr = useRef<Hmr | null>(null);@@ -270,9 +272,18 @@ export function LiveView() {}const now = performance.now();try {- const res = await engine.step(video, W, H, now / 1000);+ // Freeze this frame, find its body, then show the frame and its body together.+ const g = (grab.current ??= document.createElement("canvas"));+ if (g.width !== W || g.height !== H) Object.assign(g, { width: W, height: H });+ g.getContext("2d")?.drawImage(video, 0, 0, W, H);+ const res = await engine.step(g, W, H, now / 1000);+ const shown = frameRef.current;+ if (shown) {+ if (shown.width !== W || shown.height !== H) Object.assign(shown, { width: W, height: H });+ shown.getContext("2d")?.drawImage(g, 0, 0);+ }if (scenes.current) drawBody(scenes.current, res.verts, res.cam, res.f, W, H, now / 1000);- if (rec.current) composite(rec.current.canvas, video, overlayRef.current, mirror && source?.kind === "camera");+ if (rec.current) composite(rec.current.canvas, g, overlayRef.current, mirror && source?.kind === "camera");r.fps.push(now);while (r.fps.length > 30) r.fps.shift();if (r.fps.length % 10 === 0) {@@ -374,9 +385,10 @@ export function LiveView() {return (<div className={cn("grid gap-3", live ? "lg:grid-cols-[minmax(0,1fr)_300px]" : "mx-auto w-full max-w-[860px]")}><div ref={stageRef} className="relative overflow-hidden rounded-2xl bg-media" style={{ aspectRatio: "4 / 3" }}>- <video ref={videoRef} muted playsInline className={cn("absolute inset-0 size-full object-contain", flipped && "-scale-x-100")} />+ <video ref={videoRef} muted playsInline className="absolute inset-0 size-full object-contain opacity-0" aria-hidden />+ <canvas ref={frameRef} className={cn("absolute inset-0 size-full object-contain", flipped && "-scale-x-100")} aria-label="Your camera" /><canvas ref={overlayRef} className={cn("pointer-events-none absolute inset-0 size-full", flipped && "-scale-x-100")} aria-hidden />- {!live && <video src={LIVE_PREVIEW} autoPlay muted loop playsInline aria-hidden className="absolute inset-0 size-full object-cover" />}+ {!live && <video src={BODY_DOUBLE_DEMOS.live.video} poster={BODY_DOUBLE_DEMOS.live.poster} autoPlay muted loop playsInline aria-hidden className="absolute inset-0 size-full object-cover" />}{status.kind !== "live" && (<div className={cn("absolute inset-0 grid p-4 text-center", status.kind === "loading" ? "place-items-center bg-black/35" : "items-end justify-items-center bg-gradient-to-t from-black/75 via-black/10 to-transparent pb-6")}>{status.kind === "loading" ? (@@ -462,7 +474,7 @@ export function LiveView() {}/** The picture with the body on it, into the recording's canvas. */-function composite(canvas: HTMLCanvasElement, video: HTMLVideoElement, overlay: HTMLCanvasElement | null, flip: boolean) {+function composite(canvas: HTMLCanvasElement, video: CanvasImageSource, overlay: HTMLCanvasElement | null, flip: boolean) {const ctx = canvas.getContext("2d");if (!ctx) return;ctx.save();diff --git a/src/lib/body-double/hmr.ts b/src/lib/body-double/hmr.tsindex 63a79083..1d81eeb4 100644--- a/src/lib/body-double/hmr.ts+++ b/src/lib/body-double/hmr.ts@@ -168,8 +168,9 @@ export async function createHmr(onProgress?: (share: number) => void): Promise<Hconst cctx = crop.getContext("2d", { willReadFrequently: true }) as OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D;const input = new Float32Array(3 * SIZE * SIZE);let box: number[] | null = null;- const smoothVerts = new OneEuro(N_VERTS * 3, 1.0, 4.0);- const smoothCam = new OneEuro(3, 0.6, 2.0);+ // Light smoothing: enough to steady a still pose, quick enough to keep up with a dancer at 20 fps.+ const smoothVerts = new OneEuro(N_VERTS * 3, 3.0, 30.0);+ const smoothCam = new OneEuro(3, 2.0, 10.0);const resetTrack = () => {box = null;diff --git a/src/lib/catalog/body-double.ts b/src/lib/catalog/body-double.tsindex 004c1c7f..b41c60a3 100644--- a/src/lib/catalog/body-double.ts+++ b/src/lib/catalog/body-double.ts@@ -18,6 +18,13 @@ export const BODY_DOUBLE = {maxClipSeconds: 15,} as const;+/** Finished examples shown on the app's page: a group photo before and after, and a motion capture (also Live's opening). */+export const BODY_DOUBLE_DEMOS = {+ photo: { before: "/previews/body-double/photo-before.jpg", after: "/previews/body-double/photo-after.jpg" },+ clip: { video: "/previews/body-double/clip-demo.mp4", poster: "/previews/body-double/clip-demo.jpg" },+ live: { video: "/previews/body-double/clip-demo.mp4", poster: "/previews/body-double/clip-demo.jpg" },+} as const;+export type BodyLookId = "holo" | "clay" | "thermal" | "ghost" | "xray" | "skeleton";export type BodyLook = {diff --git a/src/lib/preset-before-after.generated.ts b/src/lib/preset-before-after.generated.tsindex d0814241..7fb4f091 100644--- a/src/lib/preset-before-after.generated.ts+++ b/src/lib/preset-before-after.generated.ts@@ -7,7 +7,7 @@export const PRESET_BEFORE_AFTER: Record<string, string> = {"app-age-shift": "b83e4f3f","app-ai-stylist": "2d44471d",- "app-body-double": "5fa15a4e",+ "app-body-double": "10054cbe","app-breakdown": "8ff71c28","app-change-background": "4814208f","app-character-swap": "cf77d26d",diff --git a/src/lib/preset-covers.generated.ts b/src/lib/preset-covers.generated.tsindex 250d51a2..1ef70f6c 100644--- a/src/lib/preset-covers.generated.ts+++ b/src/lib/preset-covers.generated.ts@@ -26,7 +26,7 @@ export const PRESET_COVERS: Record<string, PresetCoverEntry> = {"app-banana-eating": "2a384f15","app-behind-the-scenes": ["88905b1a","05e545ab"],"app-billboard-ad": ["1c66a2bd","aa072b3d"],- "app-body-double": ["09b1def0","cc37f262"],+ "app-body-double": ["126dc81a","db8221c5"],"app-breakdown": ["c7d1bbc5","6649ebea"],"app-brick-cube": ["c68c8d72","d10e386f"],"app-bring-to-life": ["6dd3e57d","17c2d9d8"],diff --git a/src/lib/preset-minis.generated.ts b/src/lib/preset-minis.generated.tsindex 83b146c7..8659444e 100644--- a/src/lib/preset-minis.generated.ts+++ b/src/lib/preset-minis.generated.ts@@ -22,7 +22,7 @@ export const PRESET_MINIS: Record<string, string> = {"app-banana-eating": "04ba3834","app-behind-the-scenes": "be67f8d3","app-billboard-ad": "9249ea4c",- "app-body-double": "772a5d8f",+ "app-body-double": "29a3a4a4","app-breakdown": "129678e2","app-brick-cube": "137c1af3","app-bring-to-life": "19e2b3ce",diff --git a/src/lib/preset-previews.generated.ts b/src/lib/preset-previews.generated.tsindex 32abc75e..56559a32 100644--- a/src/lib/preset-previews.generated.ts+++ b/src/lib/preset-previews.generated.ts@@ -155,8 +155,8 @@ export const PRESET_PREVIEWS: Record<string, PresetPreviewMedia> = {"variant": "lean-json"},"app-body-double": {- "poster": "/previews/presets/app-body-double.jpg?v=09b1def0",- "video": "/previews/presets/app-body-double.mp4?v=cc37f262",+ "poster": "/previews/presets/app-body-double.jpg?v=126dc81a",+ "video": "/previews/presets/app-body-double.mp4?v=db8221c5","run": "body-double-covers","engine": "comfyui","model": "oss-body-double",