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
Remove a person: its own Video tools tab, one click from any video, and in Assist
Claude18707aab35c1
diff --git a/src/components/cinema/cinema-feed.tsx b/src/components/cinema/cinema-feed.tsxindex 98ffbc45..ac21c231 100644--- a/src/components/cinema/cinema-feed.tsx+++ b/src/components/cinema/cinema-feed.tsx@@ -22,6 +22,7 @@ import {SlidersHorizontal,Trash2,UserRoundPlus,+ UserX,Video,X,} from "lucide-react";@@ -240,6 +241,11 @@ function TileMenu({ u, folders, projectId, handlers, onDelete }: { u: Unit; fold<DropdownMenuItem onClick={() => handlers.onReference(o.url, "video")}><ImagePlus /> Use as reference clip</DropdownMenuItem>+ <DropdownMenuItem asChild>+ <Link href={`/video-tools/remove-person?video=${encodeURIComponent(o.url)}`}>+ <UserX /> Remove a person+ </Link>+ </DropdownMenuItem></>)}{u.scenediff --git a/src/components/remove-object/hooks.ts b/src/components/remove-object/hooks.tsindex f0aa1e30..c232fc7a 100644--- a/src/components/remove-object/hooks.ts+++ b/src/components/remove-object/hooks.ts@@ -19,6 +19,8 @@ export interface RemovalBody {mask?: string;source: { url: string; name?: string; duration?: number; fps?: number; width?: number; height?: number; hasAudio?: boolean };range?: { start: number; end: number };+ /** H3 Person Removal: the person's mask grown by this many pixels. */+ maskGrow?: number;/** Client nonce: a repeat of it gets the first answer (see useSubmitGuard). */requestId?: string;}@@ -35,6 +37,8 @@ export interface RemovalEstimate {previewUsd: number | null;/** The preview is the mask the eraser works from (false: SAM 3.1's reading of the words or clicks). */previewExact: boolean;+ /** The preview is H3 Person Removal's green mask. */+ previewGreen: boolean;}/** The price and shape of a removal for the current settings, asked for once typing pauses (300 ms). */@@ -61,6 +65,13 @@ export function useRemovalActions() {void qc.invalidateQueries({ queryKey: ["generations"] });},}),+ reroll: useMutation({+ mutationFn: (b: { id: string; window: number; seed?: number; requestId?: string }) => send<{ final: Generation; items: Generation[] }>("/api/remove-object/reroll", "POST", b),+ onSuccess: (r) => {+ r.items.forEach(seed);+ void qc.invalidateQueries({ queryKey: ["generations"] });+ },+ }),preview: useMutation({mutationFn: (b: RemovalBody) => send<Generation>("/api/remove-object/preview", "POST", b),onSuccess: seed,diff --git a/src/components/remove-object/remove-object-tool.tsx b/src/components/remove-object/remove-object-tool.tsxindex ca5d2932..6abe3ec9 100644--- a/src/components/remove-object/remove-object-tool.tsx+++ b/src/components/remove-object/remove-object-tool.tsx@@ -1,11 +1,12 @@"use client";-import { Brush, Cloud, Download, Eraser as EraserIcon, Eye, Loader2, RotateCcw, Sparkles, Type, Undo2 } from "lucide-react";+import { Brush, Cloud, Cpu, Dices, Download, Eraser as EraserIcon, Eye, Loader2, RotateCcw, Sparkles, Type, Undo2 } from "lucide-react";import Link from "next/link";-import { useEffect, useMemo, useRef, useState } from "react";+import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";import { toast } from "sonner";import { Button } from "@/components/ui/button";import { Switch } from "@/components/ui/switch";+import { Input } from "@/components/ui/input";import { Textarea } from "@/components/ui/textarea";import { StepList, type StepRow } from "@/components/av/step-list";import { Panel, ToolHero, ToolShell } from "@/components/av/tool-shell";@@ -26,6 +27,7 @@ import {REMOVE,REMOVE_EXAMPLES,REMOVE_MODES,+ reviewOfOutput,type Eraser,type RemoveMode,} from "@/lib/catalog/remove-object";@@ -52,6 +54,8 @@ interface PreviewOf {id: string;exact: boolean;eraser: string;+ /** H3 Person Removal's green mask. */+ green?: boolean;}interface Run {@@ -70,7 +74,14 @@ interface Run {* result with a before / after wipe. Long clips are cut into pieces or windows, erased and joined with their* own sound (src/lib/catalog/remove-object.ts).*/-export function RemoveObjectTool({ tabs }: { tabs?: React.ReactNode }) {+/** The open eraser "Remove a person" picks: H3 Person Removal (MiniMax H3 with Akatz Labs' Person Remover). */+export const PERSON_ERASER = "oss-h3-person-remove";++const noSubscribe = () => () => {};+/** ?person=1: a result's "Remove a person" link. */+const personInUrl = () => new URLSearchParams(window.location.search).get("person") === "1";++export function RemoveObjectTool({ tabs, person = false }: { tabs?: React.ReactNode; person?: boolean }) {const [engine, setEngine, engineMode] = useEngine();// Removing an object doesn't run on an account's own GPU or key yet (only the studios' generations do): said up front,// and the upload, the mask preview and Remove are off, instead of a run the server refuses.@@ -84,7 +95,11 @@ export function RemoveObjectTool({ tabs }: { tabs?: React.ReactNode }) {const [mode, setMode] = useState<RemoveMode>("type");const [prompt, setPrompt] = useState("");const [effects, setEffects] = useState(false);+ // "Remove a person" (its own Video tools tab, or ?person=1 from a result's menu): H3 Person Removal on your GPU.+ const personLinked = useSyncExternalStore(noSubscribe, personInUrl, () => false);+ const personAsked = person || personLinked;const [picked, setPicked] = useState<Record<string, string>>({});+ const [maskGrow, setMaskGrow] = useState<number>(REMOVE.maskGrow.default);const [points, setPoints] = useState<PixelPoint[]>([]);const [pointLabel, setPointLabel] = useState<"positive" | "negative">("positive");const [paint, setPaint] = useState<Paint | null>(null);@@ -98,18 +113,30 @@ export function RemoveObjectTool({ tabs }: { tabs?: React.ReactNode }) {const previewGuard = useSubmitGuard();const history = useGenerations({ features: [REMOVE.feature], limit: 24 });+ // Hand-off: /video-tools/remove-object?video=/api/files/… (a result's menu in the Library, the feed or Cinema).+ useEffect(() => {+ const q = new URLSearchParams(window.location.search);+ const video = q.get("video");+ if (video?.startsWith("/api/files/")) source.adopt(video, video.split("/").pop());+ // Once, on arrival.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, []);+const duration = clipDuration(clip);const size = clipSize(clip);const choiceKey = `${engine}:${mode}`;// Erasers switched off in Settings → Models & licences leave the list, and the pick falls back to one that is on.const isOn = (id: string) => offered(access, id, engine);- const choice = chooseEraser({ engine, mode, effects: mode === "type" && effects, modelId: picked[choiceKey], offered: isOn });+ const choice = chooseEraser({ engine, mode, effects: mode === "type" && effects, modelId: picked[choiceKey] ?? (personAsked && choiceKey === "open:type" ? PERSON_ERASER : undefined), offered: isOn });const eraser: Eraser | null = "eraser" in choice ? choice.eraser : null;const options = keepOffered(erasersFor(engine, mode).filter((e) => !e.effects),(e) => isOn(e.id),);const everyone = !!eraser?.everyone;+ const h3 = !!eraser?.cleanFrame;+ // Removing a person with H3 runs on your GPU only (nothing hosted fills the person green for it): said on the cloud.+ const personOnCloud = personAsked && engine === "cloud";// The selection's first frame, grabbed by the browser: what points and paint are made on.const startAt = range ? Math.round(range.startTime * 100) / 100 : null;@@ -182,6 +209,7 @@ export function RemoveObjectTool({ tabs }: { tabs?: React.ReactNode }) {...(mode === "click" ? { points } : {}),...(mode === "paint" && paint ? { mask: paint.mask } : {}),...(mode !== "type" && frame ? { frame: { width: frame.width, height: frame.height } } : {}),+ ...(h3 ? { maskGrow } : {}),source: { url: clip.url!, name: clip.name, duration, fps: clip.info?.fps, width: size.width, height: size.height, hasAudio: clip.info?.hasAudio },range: { start: range.startTime, end: range.endTime },}@@ -231,7 +259,7 @@ export function RemoveObjectTool({ tabs }: { tabs?: React.ReactNode }) {const canPreview = !!body && est?.previewUsd != null;const makePreview = () => {if (visitor || !body || !canPreview || !est) return;- const of = { exact: est.previewExact, eraser: est.modelName };+ const of = { exact: est.previewExact, eraser: est.modelName, green: est.previewGreen };void previewGuard(JSON.stringify(body), (requestId) => actions.preview.mutateAsync({ ...body, requestId })).then((g) => g && setPreviewOf({ id: g.id, ...of })).catch((e: Error) => toastError(e));@@ -242,8 +270,12 @@ export function RemoveObjectTool({ tabs }: { tabs?: React.ReactNode }) {<ToolShell title="Video tools" tabs={tabs} wide selfHostedOnly>{!clip && (<ToolHero- title="Remove anything from a video"- subtitle={`Type what goes, click it, or paint over it — the gap is filled frame by frame and the sound stays${visitor ? "." : ", free on your own ComfyUI."}`}+ title={personAsked ? "Remove a person from a video" : "Remove anything from a video"}+ subtitle={+ personAsked+ ? `Name who goes, check their green mask, and the scene is rebuilt behind them — redo any part that comes out weak${visitor ? "." : ", free on your own ComfyUI."}`+ : `Type what goes, click it, or paint over it — the gap is filled frame by frame and the sound stays${visitor ? "." : ", free on your own ComfyUI."}`+ }>{visitor && <SelfHostNote className="mt-3 max-w-xl">Remove object isn't available here.</SelfHostNote>}</ToolHero>@@ -323,7 +355,7 @@ export function RemoveObjectTool({ tabs }: { tabs?: React.ReactNode }) {)}<p className="mt-2 text-[12px] text-muted-foreground">{frameHint(mode, engine, points.length, !!paint)}</p>{/* Said for the eraser picked now (the preview itself is SAM's, whichever eraser runs). */}- {preview && previewOf && <MaskPreview g={preview} exact={est?.previewExact ?? previewOf.exact} eraser={est?.modelName ?? previewOf.eraser} />}+ {preview && previewOf && <MaskPreview g={preview} exact={est?.previewExact ?? previewOf.exact} eraser={est?.modelName ?? previewOf.eraser} green={previewOf.green} />}</Panel></div></div>@@ -442,11 +474,46 @@ export function RemoveObjectTool({ tabs }: { tabs?: React.ReactNode }) {</p>)}+ {personOnCloud && (+ <div className="space-y-2 rounded-xl bg-muted/60 p-3 text-[13px]" role="status">+ <p className="flex gap-1.5">+ <Cpu className="mt-0.5 size-3.5 shrink-0" />+ <span>+ Removing a person with MiniMax H3 runs on your GPU (open source): the person is filled green and the scene rebuilt behind them. In the cloud, Kling O3 Omni or Bria erase who you name, and LTX+ Clean Plate removes everyone.+ </span>+ </p>+ {engineMode === "both" && (+ <Button size="sm" variant="outline" className="rounded-full" onClick={() => setEngine("open")}>+ <Cpu className="size-3.5" /> Use your GPU+ </Button>+ )}+ </div>+ )}++ {h3 && (+ <Field label="Mask expansion" htmlFor="remove-grow" hint={`${REMOVE.maskGrow.min}–${REMOVE.maskGrow.max} px`}>+ <div className="flex items-center gap-2">+ <Input+ id="remove-grow"+ type="number"+ inputMode="numeric"+ min={REMOVE.maskGrow.min}+ max={REMOVE.maskGrow.max}+ value={maskGrow}+ onChange={(e) => setMaskGrow(Math.max(REMOVE.maskGrow.min, Math.min(REMOVE.maskGrow.max, Math.round(Number(e.target.value) || 0))))}+ className="h-9 w-24"+ />+ <span className="text-[12px] leading-snug text-muted-foreground">Grow it if a hand, hair or shadow shows outside the green; more makes H3 invent more background.</span>+ </div>+ </Field>+ )}+<div className="space-y-3 border-t pt-3">{body && est?.previewUsd != null && (<div className="flex items-center gap-2"><Button variant="outline" size="sm" className="rounded-full" onClick={makePreview} disabled={actions.preview.isPending || (preview && (preview.status === "queued" || preview.status === "running")) || visitor}>- {actions.preview.isPending ? <Loader2 className="size-3.5 animate-spin" /> : <Eye className="size-3.5" />} Preview the mask+ {actions.preview.isPending ? <Loader2 className="size-3.5 animate-spin" /> : <Eye className="size-3.5" />} {est.previewGreen ? "Check the green mask" : "Preview the mask"}</Button><span className="min-w-0 text-[12px] leading-snug text-muted-foreground">first {REMOVE.previewSeconds} s · {est.demo ? "demo" : engine === "open" ? (visitor ? "not available here" : "free") : costText({ costUsd: est.previewUsd, demo: false }, "cloud")}@@ -492,7 +559,7 @@ export function RemoveObjectTool({ tabs }: { tabs?: React.ReactNode }) {)}</div>- {run && <RunPanel run={run} onAgain={start} />}+ {run && <RunPanel run={run} onAgain={start} onRedo={(r) => setRun({ ...run, final: r.final.id, ids: r.items.map((g) => g.id) })} />}{(history.data?.length ?? 0) > 0 && (<section className="mt-10" aria-labelledby="removals">@@ -555,12 +622,16 @@ function EraserList({ options, value, onChange }: { options: Eraser[]; value: st* The mask preview: SAM 3.1's mask video (cloud) or the SAM 3 matte (open), white = what goes. When the eraser finds* the object itself (Kling O3 edit, Bria by name, Bria's own clicks), it's only SAM 3.1's reading of what you said.*/-function MaskPreview({ g, exact, eraser }: { g: Generation; exact: boolean; eraser: string }) {+function MaskPreview({ g, exact, eraser, green }: { g: Generation; exact: boolean; eraser: string; green?: boolean }) {const out = g.outputs.find((o) => o.kind === "video");return (<div className="mt-3 rounded-xl border p-2.5"><p className="mb-2 text-[12px] font-medium">- {exact ? (+ {green ? (+ <>+ Green mask <span className="font-normal text-muted-foreground">· green is what H3 rebuilds — keep every part of the person covered</span>+ </>+ ) : exact ? (<>Mask preview <span className="font-normal text-muted-foreground">· white is what goes</span></>@@ -590,8 +661,8 @@ function MaskPreview({ g, exact, eraser }: { g: Generation; exact: boolean; eras);}-/** What a removal's steps are doing, then the result with a before / after wipe. */-function RunPanel({ run, onAgain }: { run: Run; onAgain: () => void }) {+/** What a removal's steps are doing, then the result with a before / after wipe (and, for H3, each window to redo). */+function RunPanel({ run, onAgain, onRedo }: { run: Run; onAgain: () => void; onRedo: (r: { final: Generation; items: Generation[] }) => void }) {const list = useGenerationList(run.ids).data;const byId = useMemo(() => new Map((list ?? []).map((g) => [g.id, g])), [list]);const final = byId.get(run.final);@@ -620,7 +691,10 @@ function RunPanel({ run, onAgain }: { run: Run; onAgain: () => void }) {}>{out ? (- <VideoCompare before={run.before} after={out.url} start={run.start} ratio={run.ratio} />+ <>+ <VideoCompare before={run.before} after={out.url} start={run.start} ratio={run.ratio} />+ {(list ?? []).map((g) => (reviewOfOutput(g.outputs.find((o) => o.kind === "video")?.meta) ? <WindowReview key={g.id} g={g} onRedo={onRedo} /> : null))}+ </>) : (<div className="space-y-3"><div className="h-1.5 overflow-hidden rounded-full bg-muted" role="progressbar" aria-valuemin={0} aria-valuemax={100} aria-valuenow={Math.round(state.progress * 100)} aria-label="Progress">@@ -636,3 +710,63 @@ function RunPanel({ run, onAgain }: { run: Run; onAgain: () => void }) {</section>);}++/**+ * H3 Person Removal's windows (H3 Relay's Review Windows): each 22-frame window's preview, and "Redo from here" with a+ * new seed — every window before it comes back exactly, the ones after it continue from the new one.+ */+function WindowReview({ g, onRedo }: { g: Generation; onRedo: (r: { final: Generation; items: Generation[] }) => void }) {+ const review = reviewOfOutput(g.outputs.find((o) => o.kind === "video")?.meta)!;+ const actions = useRemovalActions();+ const guard = useSubmitGuard();+ const [busy, setBusy] = useState<number | null>(null);+ const redo = (index: number) => {+ // A new seed for the window: the server draws one.+ const body = { id: g.id, window: index };+ setBusy(index);+ void guard(`${g.id}:${index}`, (requestId) => actions.reroll.mutateAsync({ ...body, requestId }))+ .then((r) => {+ if (!r) return;+ onRedo(r);+ toast(`Redoing from window ${index + 1}`, { description: "The windows before it stay exactly as they are." });+ })+ .catch((e: Error) => toastError(e))+ .finally(() => setBusy(null));+ };+ const fps = 24;+ return (+ <div className="mt-4 space-y-2">+ <div className="flex flex-wrap items-baseline justify-between gap-2">+ <h4 className="text-[13px] font-medium">Windows</h4>+ <p className="text-[12px] text-muted-foreground">A weak part? Redo it with a new seed — every window before it is kept.</p>+ </div>+ <ul className="grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4">+ {review.windows.map((w) => {+ const video = w.video ? review.links[w.video] : undefined;+ const poster = w.poster ? review.links[w.poster] : undefined;+ const from = (w.start / fps).toFixed(1);+ return (+ <li key={w.index} className="min-w-0 rounded-xl border p-2">+ {video && /^\/api\/files\//.test(video) ? (+ <video src={video} poster={poster} muted loop playsInline controls className="aspect-video w-full rounded-lg bg-media object-cover" />+ ) : poster && /^(\/api\/files\/|data:)/.test(poster) ? (+ // eslint-disable-next-line @next/next/no-img-element+ <img src={poster} alt={`Window ${w.index + 1}`} className="aspect-video w-full rounded-lg bg-media object-cover" />+ ) : (+ <div className="grid aspect-video w-full place-items-center rounded-lg bg-muted text-[12px] text-muted-foreground">No preview</div>+ )}+ <div className="mt-1.5 flex items-center justify-between gap-1">+ <span className="min-w-0 truncate text-[12px] text-muted-foreground">+ {w.index + 1} · {from} s{w.reused ? " · kept" : ""}+ </span>+ <Button size="sm" variant="ghost" className="h-7 shrink-0 rounded-full px-2 text-[12px]" disabled={busy !== null} onClick={() => redo(w.index)} aria-label={`Redo from window ${w.index + 1}`}>+ {busy === w.index ? <Loader2 className="size-3 animate-spin" /> : <Dices className="size-3" />} Redo from here+ </Button>+ </div>+ </li>+ );+ })}+ </ul>+ </div>+ );+}diff --git a/src/components/studio/mode-switch-studio.tsx b/src/components/studio/mode-switch-studio.tsxindex b3cbf548..b112eb31 100644--- a/src/components/studio/mode-switch-studio.tsx+++ b/src/components/studio/mode-switch-studio.tsx@@ -68,6 +68,7 @@ const TOOLS: Partial<Record<HubKind, Record<string, (p: { tabs: React.ReactNode},"video-tools": {"remove-object": ({ tabs }) => <RemoveObjectTool tabs={tabs} />,+ "remove-person": ({ tabs }) => <RemoveObjectTool tabs={tabs} person />,"remove-dialogue": ({ tabs }) => <RemoveDialogueTool tabs={tabs} />,evolution: ({ tabs }) => <EvolutionTool tabs={tabs} />,restore: ({ tabs }) => <RestoreTool tabs={tabs} />,diff --git a/src/components/studio/result-actions.tsx b/src/components/studio/result-actions.tsxindex 758ed278..55da7921 100644--- a/src/components/studio/result-actions.tsx+++ b/src/components/studio/result-actions.tsx@@ -22,6 +22,7 @@ import {LayoutDashboard,Mic2,MicOff,+ UserX,MoreHorizontal,Pin,Repeat,@@ -98,6 +99,7 @@ export const ACTION_ICONS: Record<OutputActionId, LucideIcon> = {"loop-audio": Repeat,"split-soundtrack": SlidersVertical,"remove-dialogue": MicOff,+ "remove-person": UserX,"clean-voice": AudioWaveform,"copy-text": Copy,"view-3d": Box,diff --git a/src/lib/hubs.ts b/src/lib/hubs.tsindex 1b3161c3..5e72bb83 100644--- a/src/lib/hubs.ts+++ b/src/lib/hubs.ts@@ -31,6 +31,7 @@ export const HUB_MODES: Record<HubKind, { id: string; label: string }[]> = {{ id: "matte", label: "Remove background" },{ id: "remove-object", label: "Remove object" },{ id: "remove-dialogue", label: "Remove dialogue" },+ { id: "remove-person", label: "Remove a person" },{ id: "evolution", label: "Evolution" },{ id: "restore", label: "Restore & colourise" },{ id: "relight", label: "Relight" },diff --git a/src/lib/output-actions.ts b/src/lib/output-actions.tsindex eece3a23..ad2349f1 100644--- a/src/lib/output-actions.ts+++ b/src/lib/output-actions.ts@@ -34,6 +34,7 @@ export type OutputActionId =| "loop-audio"| "split-soundtrack"| "remove-dialogue"+ | "remove-person"| "clean-voice"| "copy-text"| "view-3d"@@ -143,6 +144,8 @@ export function outputActions(g: Generation, index: number, ctx: ActionContext =link("add-sound", "Add sound", `/audio/video?video=${q(o.url)}`);link("split-soundtrack", "Split soundtrack", `/audio/split?video=${q(o.url)}`);link("remove-dialogue", "Remove dialogue", `/video-tools/remove-dialogue?video=${q(o.url)}`);+ // H3 Person Removal (o/person-remover-plus): Video tools → Remove a person with the clip in.+ link("remove-person", "Remove a person", `/video-tools/remove-person?video=${q(o.url)}`);// Clean up voice on a video's soundtrack: results that carry sound, and uploads (a clip from a phone or a call).if (g.feature === "upload" || (g.op && SOUNDED_VIDEO_OPS.has(g.op))) link("clean-voice", "Clean up voice", `/audio/clean?video=${q(o.url)}`);// A Fuobe DoP colour-grade effect: the clip opens in Color grading with its grade picked (one click to export).diff --git a/src/server/assist/studio-routes.ts b/src/server/assist/studio-routes.tsindex 0dad3145..af8a947a 100644--- a/src/server/assist/studio-routes.ts+++ b/src/server/assist/studio-routes.ts@@ -24,10 +24,11 @@ import { createProject, deleteProject, FileUrl, jobSteps, startJob } from "../laimport { firstOn } from "../model-access";import { engineMode } from "../settings";import { createRestore, estimateRestore, RestoreBodySchema, RestoreEstimateSchema } from "../restore";+import { createRemoval, estimateRemovalNow, RemovalBodySchema, RemovalEstimateSchema } from "../remove-object";import { createSession, estimateWith, sourceInfo, type ShortsBody, type SourceInfo } from "../shorts";import { absolutePath, getAsset } from "../storage";import type { ToolContext } from "./define";-import { planSteps, STUDIO_ROUTES, type AdsToolInput, type CaptionsToolInput, type DubToolInput, type FacelessToolInput, type LayersToolInput, type RestoreToolInput, type RestyleToolInput, type StudioRoute } from "./studio-tools";+import { planSteps, STUDIO_ROUTES, type RemovePersonToolInput, type AdsToolInput, type CaptionsToolInput, type DubToolInput, type FacelessToolInput, type LayersToolInput, type RestoreToolInput, type RestyleToolInput, type StudioRoute } from "./studio-tools";/*** The Assist / MCP studio tools, wired to the studios' own server modules: each adapter turns a tool@@ -699,6 +700,56 @@ function parsed<T>(schema: { safeParse: (v: unknown) => { success: true; data: Treturn r.data;}+// ---------------------------------------------------------------------------+// Remove a person: H3 Person Removal in Video tools → Remove a person (src/server/remove-object.ts)++function removePersonBody(i: RemovePersonToolInput) {+ const info = clipInfo(i.video);+ const end = i.end ?? info?.duration;+ return {+ engine: "open" as const,+ mode: "type" as const,+ modelId: "oss-h3-person-remove",+ prompt: i.who,+ ...(i.mask_grow !== undefined && { maskGrow: i.mask_grow }),+ source: { url: i.video, name: fileTitle(i.video), duration: info?.duration, fps: info?.fps, width: info?.width, height: info?.height, hasAudio: info?.hasAudio },+ ...(end !== undefined && { range: { start: i.start ?? 0, end } }),+ };+}++const removePersonRoute: StudioRoute<RemovePersonToolInput> = {+ studio: "Remove a person",+ page: modeHref("video-tools", "remove-person"),+ // Only a clip Fuobe has (and can read) can be fitted to H3's frame rate and size.+ refuse: (i) => (i.video.startsWith("/api/files/") && clipInfo(i.video)?.duration ? null : "Fuobe couldn't read this clip's length and frame rate"),+ plan: (i) => {+ const est = estimateRemovalNow(parsed(RemovalEstimateSchema, removePersonBody(i)));+ return [+ {+ tool: "remove_person",+ modelId: est.modelId,+ modelName: est.modelName,+ kind: "video",+ op: "remove-object",+ prompt: i.who,+ count: 1,+ costUsd: est.costUsd,+ demo: est.demo,+ note: [`${est.seconds} s`, ...est.notes].join(" · "),+ atomic: true,+ },+ ];+ },+ async run(i) {+ const r = await createRemoval(parsed(RemovalBodySchema, removePersonBody(i)));+ return {+ ids: [r.final.id],+ href: modeHref("video-tools", "remove-person"),+ info: { note: "The removal is listed under Your removals in Remove a person, beside the original with a Before/After wipe; each window there can be redone." },+ };+ },+};+const restoreRoute: StudioRoute<RestoreToolInput> = {studio: "Restore & colourise",page: modeHref("video-tools", "restore"),@@ -738,3 +789,4 @@ STUDIO_ROUTES.faceless_episode = facelessRoute;STUDIO_ROUTES.create_ads = adsRoute;STUDIO_ROUTES.add_captions = captionsRoute;STUDIO_ROUTES.restore_video = restoreRoute;+STUDIO_ROUTES.remove_person = removePersonRoute;diff --git a/src/server/assist/studio-tools.ts b/src/server/assist/studio-tools.tsindex 81010ff9..b384785e 100644--- a/src/server/assist/studio-tools.ts+++ b/src/server/assist/studio-tools.ts@@ -13,6 +13,7 @@ import type { ChainSlot, Engine, GenerationRequest, Operation } from "@/lib/cataimport { TOOL_MODELS } from "@/lib/layers";import { planCinema } from "@/lib/catalog/cinema";import { createPipeline, type PipelineStep } from "../chains";+import { getEraser, planRemoval, REMOVE, removalTitle } from "@/lib/catalog/remove-object";import { blockoutFromFile, cinemaContext } from "../cinema-generate";import { db } from "../db";import { chooseRoute, ConnectComfyError, createGenerations, outputKind, previewChained } from "../generations";@@ -154,6 +155,14 @@ const RestoreInput = z.object({resolution: z.enum(["720p", "1080p"]).optional().describe("Cloud size (default 720p)."),});+const RemovePersonInput = z.object({+ video: ref.describe("The clip to remove someone from."),+ who: z.string().max(200).describe("Who to remove, as SAM 3.1 should find them: 'the man in the grey shirt', 'the woman on the left'."),+ start: z.number().min(0).max(3600).optional().describe("Seconds into the clip where the part starts (default 0)."),+ end: z.number().min(0).max(3600).optional().describe("Seconds where it ends (default the clip's end; up to 60 s at a time)."),+ mask_grow: z.number().int().min(0).max(64).optional().describe("Grow the person's mask by this many pixels (default 5): more covers hands, hair and shadows, but H3 invents more background."),+});+const BlockoutInput = z.object({video: ref.describe("The grey-box blockout: a render from Blender, Unreal, Cinema 4D… (MP4 or MOV for the cloud), 2–60 s. It sets the camera, blocking and timing."),depth: ref.optional().describe("Your GPU: the blockout's depth pass (near = bright). Without it Depth Anything 3 reads the depth from the grey box."),@@ -182,6 +191,7 @@ const BlockoutInput = z.object({export type LayersToolInput = z.infer<typeof LayersInput>;export type BlockoutToolInput = z.infer<typeof BlockoutInput>;export type RestoreToolInput = z.infer<typeof RestoreInput>;+export type RemovePersonToolInput = z.infer<typeof RemovePersonInput>;export type RestyleToolInput = z.infer<typeof RestyleInput>;export type DubToolInput = z.infer<typeof DubInput>;export type FacelessToolInput = z.infer<typeof FacelessInput>;@@ -197,6 +207,7 @@ export const STUDIO_ROUTES: {create_ads?: StudioRoute<AdsToolInput>;add_captions?: StudioRoute<CaptionsToolInput>;restore_video?: StudioRoute<RestoreToolInput>;+ remove_person?: StudioRoute<RemovePersonToolInput>;} = {};// ---------------------------------------------------------------------------@@ -704,6 +715,41 @@ const restoreVideo = defineTool({},});+/**+ * A clip Remove a person can't read (its length and size unknown): the same H3 removal as separate steps in the Library,+ * on the part asked for (else up to a minute from its start), without its sound.+ */+function removePersonSteps(i: RemovePersonToolInput): PipelineStep[] {+ const start = i.start ?? 0;+ const plan = planRemoval({+ engine: "open",+ mode: "type",+ eraser: getEraser("oss-h3-person-remove")!,+ title: removalTitle({ mode: "type", prompt: i.who }),+ source: { url: i.video, hasAudio: false },+ range: { start, end: i.end ?? start + REMOVE.maxSeconds },+ prompt: i.who,+ ...(i.mask_grow !== undefined && { maskGrow: i.mask_grow }),+ });+ return plan.steps.map((s) => ({ key: s.key, request: { ...s.request, feature: s.request.feature ?? "assist" }, ...(s.after?.length && { after: s.after, chain: s.chain }) }));+}++/** Remove a person (o/person-remover-plus): Video tools → Remove a person, H3 Person Removal on your GPU. */+const removePerson = defineTool({+ name: "remove_person",+ description:+ "Remove a person from a video and rebuild the scene behind them — Fuobe's Remove a person (Video tools → Remove a person): MiniMax H3 with Akatz Labs' Person Remover LoRA on your GPU (open source, free), from a clean first frame Qwen-Image 2.1 makes, in 22-frame windows; the clip's sound is kept. " ++ "It runs on your GPU only (24 GB with offloading and the H3 Relay nodes). In the studio the user can check the green mask first and redo any weak window. For objects, or on the cloud, use generate with a remove-object model. Gated by the same approval card as generate.",+ schema: RemovePersonInput,+ gated: true,+ title: (i) => `Remove · ${i.who.slice(0, 60)}`,+ place: (i, ctx) => placeFor(STUDIO_ROUTES.remove_person, i, ctx),+ plan: (i, ctx) => planVia("remove_person", STUDIO_ROUTES.remove_person, i, ctx, () => planSteps("remove_person", removePersonSteps(i))),+ async run(i, ctx) {+ return runVia(STUDIO_ROUTES.remove_person, i, ctx, "Started removing the person", () => startPipeline("Remove a person", removePersonSteps(i), removalTitle({ mode: "type", prompt: i.who })));+ },+});+/*** Blockout to film (package blockout-film): Cinema's Blockout plan (src/lib/catalog/cinema.ts planBlockout), run as a* pipeline in the Library: one call or shots cut at the beats and joined in the cloud, 81-frame depth windows on the GPU.@@ -771,7 +817,7 @@ const blockoutFilm = defineTool({},});-export const STUDIO_TOOLS = [splitLayers, restyleFootage, dubVideo, facelessEpisode, createAds, addCaptions, restoreVideo, blockoutFilm];+export const STUDIO_TOOLS = [splitLayers, restyleFootage, dubVideo, facelessEpisode, createAds, addCaptions, restoreVideo, removePerson, blockoutFilm];/** For tests: the fallback pipelines, as they would be created. */export const fallbackSteps = { restore: restoreSteps, layers: layerSteps, restyle: restyleSteps, dub: dubSteps, faceless: facelessSteps, captions: captionSteps, ads: adRequests, blockout: blockoutSteps };diff --git a/src/server/gpu/tools.ts b/src/server/gpu/tools.tsindex b4f9e5a1..47ddff23 100644--- a/src/server/gpu/tools.ts+++ b/src/server/gpu/tools.ts@@ -4,11 +4,11 @@ import { SPLIT_MODEL } from "@/lib/av/split";import { REMOVE_DIALOGUE_MODELS } from "@/lib/av/remove-dialogue";import { CLEAN_MODEL } from "@/lib/av/clean-voice";import { getModel, getPreset, MODELS, modelsFor, PRESETS } from "@/lib/catalog";-import { graphLoras } from "@/lib/catalog/character-swap";+import { graphLoras, PERSON_REMOVER_LORA } from "@/lib/catalog/character-swap";import { BLOCKOUT_MODELS, PATH_MODELS } from "@/lib/catalog/cinema";import { dualEngine, onEngine, runsOn } from "@/lib/catalog/engines";import { FRAMES_MODELS } from "@/lib/catalog/keyframes";-import { REMOVE_TOOLS } from "@/lib/catalog/remove-object";+import { PERSON_REMOVAL_TOOLS, REMOVE_TOOLS } from "@/lib/catalog/remove-object";import { RESTORE, RESTORE_OPEN_JOIN } from "@/lib/catalog/restore";import { REGEN_DEFAULT_TIER, REGEN_JOIN, REGEN_MODEL, regenerateGraphLoras } from "@/lib/catalog/regenerate";import { libraryEntry, loraEntry, loraRef, needsToken } from "@/lib/catalog/loras";@@ -266,6 +266,21 @@ export const STUDIO_ROWS: StudioRowDef[] = [{ modelId: REMOVE_DIALOGUE_MODELS.mux, op: "mux" },],},+ // Remove a person (o/person-remover-plus): the part fitted to 24 fps, its first frame cleaned by Qwen-Image 2.1, the green+ // mask preview, H3 Relay's Person Removal with Akatz Labs' Person Remover LoRA, and the sound put back.+ {+ href: "/video-tools/remove-person",+ label: "Remove a person",+ group: "Video tools",+ steps: [+ { modelId: "oss-h3-person-remove", op: "remove-object", loras: [PERSON_REMOVER_LORA] },+ { modelId: PERSON_REMOVAL_TOOLS.mask, op: "bg-remove-video" },+ { modelId: PERSON_REMOVAL_TOOLS.fit, op: "trim" },+ { modelId: PERSON_REMOVAL_TOOLS.frame, op: "frame" },+ { modelId: PERSON_REMOVAL_TOOLS.clean, op: "edit" },+ { modelId: REMOVE_TOOLS.open.mux, op: "mux" },+ ],+ },{ href: "/video-tools/relight", label: "Relight", group: "Video tools", config: S.VIDEO_RELIGHT_STUDIO },{ href: "/video-tools/depth", label: "Depth map", group: "Video tools", config: S.VIDEO_DEPTH_STUDIO },{ href: "/video-tools/join", label: "Join clips", group: "Video tools", config: S.JOIN_CLIPS_STUDIO },diff --git a/src/server/providers/mock.ts b/src/server/providers/mock.tsindex 1f8bfff4..4b31c399 100644--- a/src/server/providers/mock.ts+++ b/src/server/providers/mock.ts@@ -3,7 +3,8 @@ import fs from "node:fs";import path from "node:path";import { nanoid } from "nanoid";import { cueText, parseCues, type Cue } from "@/lib/cues";-import { HAND_OFF } from "@/lib/catalog/remove-object";+import { H3_REMOVAL_WORKFLOW } from "@/lib/catalog/character-swap";+import { HAND_OFF, windowArtifact } from "@/lib/catalog/remove-object";import { OPERATION_OUTPUT, type MediaKind, type Operation } from "@/lib/catalog/types";import { spectralColor } from "@/lib/scene3d";import type { ProviderAdapter, RemoteOutput } from "./types";@@ -339,7 +340,7 @@ function demoOutputs(op: Operation | undefined, kind: MediaKind, prompt: string,return [{ url: toDataUri(demoWav(clamp(3 * Number(meta.clips ?? 2), 4, 30), [330, 495]), "audio/wav"), kind: "audio", contentType: "audio/wav", meta: { demo: true } }];case "remove-object":return [- { url: `sample:${sampleClip(ar)}`, kind: "video", contentType: "video/mp4", meta: { demo: true } },+ { url: `sample:${sampleClip(ar)}`, kind: "video", contentType: "video/mp4", meta: { demo: true, ...(meta.h3Review ? demoRemovalReview(ar) : {}) } },// The painted eraser also hands the window's last tracked mask to the next window....(meta.lastMask ? [{ url: svgUri(demoMaskSvg(ar)), kind: "image" as const, contentType: "image/svg+xml", meta: { role: "mask", demo: true } }] : []),];@@ -381,6 +382,15 @@ function demoOutputs(op: Operation | undefined, kind: MediaKind, prompt: string,return [{ url: `sample:${sampleClip(ar)}`, kind: "video", contentType: "video/mp4", ...(meta.draft ? { draftId: `demo_draft_${nanoid(8)}` } : {}) }];}+/** A demo of H3 Relay's window review: three 22-frame windows, each with a still and a checkpoint. */+function demoRemovalReview(ar: string): Record<string, unknown> {+ const hex = (n: number, len: number) => String(n).repeat(len).slice(0, len);+ const windows = [0, 1, 2].map((index) => ({ index, start: index * 22, frames: 22, seed: String(904234 + index), recordId: hex(index + 1, 32), poster: windowArtifact(index, "poster") }));+ const artifacts: Record<string, string> = {};+ for (const w of windows) artifacts[w.poster] = svgUri(demoSvg(`window ${w.index + 1}`, ar, w.index));+ return { review: { runId: hex(9, 32), configKey: hex(8, 64), seed: "904234", total: 3, windows, reuse: { video: "fuobe_demo0001.mp4", image: "fuobe_demo0002.png", prefix: "fuobe/demo" } }, artifacts };+}+export const mockProvider: ProviderAdapter = {id: "mock",label: "Placeholder",@@ -420,6 +430,8 @@ export const mockProvider: ProviderAdapter = {firstFrame: route.provider === "comfyui" && route.endpoint === "video-segment-resample",// Character Swap Studio's segment graph: the take and its lossless master (video-character-swap-h3-segment).master: route.provider === "comfyui" && route.endpoint === "video-character-swap-h3-segment",+ // H3 Person Removal: each window's preview and checkpoint, so "Redo from here" can be tried (H3 Relay's review).+ h3Review: route.provider === "comfyui" && route.endpoint === H3_REMOVAL_WORKFLOW,// A stem split that also transcribes (ComfyUI's dub-prepare-separate-transcribe).transcript: route.op === "separate-audio" && route.provider === "comfyui" && route.endpoint.includes("transcribe"),// A dialogue / music / effects split (ComfyUI's separate-soundtrack-dbs): four stems.diff --git a/src/server/remove-object.ts b/src/server/remove-object.tsindex f8c3aacc..bfadc7ed 100644--- a/src/server/remove-object.ts+++ b/src/server/remove-object.ts@@ -158,12 +158,18 @@ interface Planned {}async function planInput(body: RemovalBody, opts: { probe: boolean; preview?: boolean }): Promise<Planned> {+ const info = opts.probe ? await probeSource(body.source.url) : {};+ const painted = body.mode === "paint" && body.engine === "cloud" && opts.probe && body.mask ? await pointsFromPaint(body.mask, { width: info.width ?? body.source.width, height: info.height ?? body.source.height }) : undefined;+ return planInputNow(body, opts, info, painted);+}++/** planInput once the clip's header and the paint's points are read (nothing to wait for). */+function planInputNow(body: RemovalBody, opts: { probe: boolean; preview?: boolean }, info: Awaited<ReturnType<typeof probeSource>> | Record<string, never>, painted?: PixelPoint[]): Planned {mustMatchMode(body.engine);const picked = chooseEraser({ engine: body.engine, mode: body.mode, effects: body.effects, modelId: body.modelId, offered: (id) => isOffered(id, body.engine) });if ("problem" in picked) throw new ShortsError(picked.problem, 422);const eraser = picked.eraser;// The header's facts win over what the browser read (the estimate runs before the upload is read).- const info = opts.probe ? await probeSource(body.source.url) : {};const source: RemoveSource = {url: body.source.url,duration: info.duration ?? body.source.duration,@@ -193,7 +199,7 @@ async function planInput(body: RemovalBody, opts: { probe: boolean; preview?: boif (body.mode === "paint") {if (!body.mask) throw new ShortsError("Paint over what to remove first");// The cloud's tracker takes points, not paint; the open graph reads the mask itself.- if (eraser.engine === "cloud") points = opts.probe ? await pointsFromPaint(body.mask, source) : [{ x: 1, y: 1, label: "positive" }];+ if (eraser.engine === "cloud") points = painted ?? [{ x: 1, y: 1, label: "positive" }];}const notes: string[] = [];@@ -302,7 +308,12 @@ export interface RemovalEstimate {}export async function estimateRemoval(body: RemovalBody): Promise<RemovalEstimate> {- const { input, eraser, notes } = await planInput(body, { probe: false });+ return estimateRemovalNow(body);+}++/** The estimate without waiting (it reads nothing: the browser's facts stand in for the header). */+export function estimateRemovalNow(body: RemovalBody): RemovalEstimate {+ const { input, eraser, notes } = planInputNow(body, { probe: false }, {});const plan = planRemoval(input);const preview = planMaskPreview(input);return {diff --git a/tests/assist-context.test.ts b/tests/assist-context.test.tsindex 8ab60932..f9c64300 100644--- a/tests/assist-context.test.ts+++ b/tests/assist-context.test.ts@@ -374,6 +374,7 @@ describe("studio tools", () => {create_ads: [{ brief: "oat milk for runners" }, { brief: "oat milk", product_image: image, count: 2, aspect_ratios: ["1:1", "9:16"] }],add_captions: [{ video }, { video, translate_to: "Spanish" }],restore_video: [{ video }, { video, prompt: "a harbour in the 1930s, natural colour", reference: image }],+ remove_person: [{ video, who: "the man in the grey shirt" }, { video, who: "the woman on the left", start: 0, end: 1, mask_grow: 9 }],blockout_film: [{ video, seconds: 8, beats: [{ start: 0, label: "Arrival", words: "She walks in." }] },{ video, seconds: 40, beats: [{ start: 0, label: "Arrival" }, { start: 20, label: "Lights out" }], references: [{ url: image, role: "character", name: "Mara" }], model: "minimax-h3-max-3d", sounds: ["Footsteps"] },@@ -389,6 +390,12 @@ describe("studio tools", () => {for (const input of inputs)for (const engine of ["cloud", "open"] as const) {const p = plan(name, input, engine);+ // Remove a person runs on your GPU only (MiniMax H3 with the Person Remover LoRA): an install that runs the+ // cloud alone says so on the card.+ if (name === "remove_person" && mode === "cloud") {+ expect(p.jobs.find((j) => j.error)?.error ?? p.error, `${name} ${engine}/${mode}`).toBeTruthy();+ continue;+ }expect(p.error, `${name} ${engine}/${mode}`).toBeUndefined();expect(p.jobs.length, `${name} ${engine}/${mode}`).toBeGreaterThan(0);for (const j of p.jobs) expect(j.error, `${name} ${engine}/${mode}: ${j.modelId}`).toBeUndefined();diff --git a/tests/library-pure.test.ts b/tests/library-pure.test.tsindex 676ea97a..60913582 100644--- a/tests/library-pure.test.ts+++ b/tests/library-pure.test.ts@@ -115,6 +115,7 @@ describe("outputActions", () => {"menu:add-sound","menu:split-soundtrack","menu:remove-dialogue",+ "menu:remove-person","menu:grade","menu:genjutsu","menu:finalize",