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.

Video tools: Remove object shows its mode's examples, and opens with an example's clip and words

Adarsh8eb2405e5367
diff --git a/src/components/remove-object/remove-object-tool.tsx b/src/components/remove-object/remove-object-tool.tsx
index fe7eb6b1..0acce084 100644
--- a/src/components/remove-object/remove-object-tool.tsx
+++ b/src/components/remove-object/remove-object-tool.tsx
@@ -42,6 +42,8 @@ import { toastError } from "@/lib/refusals";
import { FrameStage, frameFromBlob, type Frame } from "./frame-stage";
import { useRemovalActions, useRemovalEstimate, type RemovalBody } from "./hooks";
import { VideoCompare } from "./video-compare";
+import { ExampleRow } from "@/components/studio/example-row";
+import type { ExampleRowData } from "@/lib/examples/types";
const LIMITS = `MP4, MOV or WebM · up to ${REMOVE.maxSeconds} s at a time · ${REMOVE.maxBytes / 1024 / 1024} MB`;
@@ -79,11 +81,15 @@ interface Run {
/** 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";
+/** An example's clip a link may hand over: a published example file. */
+const EXAMPLE_CLIP = /^\/examples\/[a-z0-9-]+\/\d+\/[a-z0-9-]+\.mp4$/;
+
const noSubscribe = () => () => {};
/** ?person=1: a result's "Remove a person" link. */
const personInUrl = () => new URLSearchParams(window.location.search).get("person") === "1";
-export function RemoveObjectTool({ person = false }: { person?: boolean } = {}) {
+/** examples: the mode's examples (exampleRow(), from the page), under the clip drop until there is a run of one's own; each opens this tool with its clip and words in. */
+export function RemoveObjectTool({ person = false, examples }: { person?: boolean; examples?: ExampleRowData | null } = {}) {
const [engine, setEngine, engineMode] = useEngine();
const access = useModelAccess();
const source = useSourceClip(REMOVE.maxBytes);
@@ -115,11 +121,19 @@ export function RemoveObjectTool({ person = false }: { person?: boolean } = {})
const reviewable = useGenerations({ features: [REMOVE.feature, REMOVE.stepFeature], models: [PERSON_ERASER], statuses: ["succeeded"], limit: 12 });
const earlier = (reviewable.data ?? []).filter((g) => !run?.ids.includes(g.id) && reviewOfOutput(g.outputs.find((o) => o.kind === "video")?.meta));
- // Hand-off: /video-tools/remove-object?video=/api/files/… (a result's menu in the Library, the feed or Cinema).
+ // Hand-off: /video-tools/remove-object?video=/api/files/… (a result's menu in the Library, the feed or Cinema), or an
+ // example's clip (/examples/…) with what to remove (?prompt=).
useEffect(() => {
const q = new URLSearchParams(window.location.search);
const video = q.get("video");
- if (video?.startsWith("/api/files/")) source.adopt(video, video.split("/").pop());
+ if (video?.startsWith("/api/files/") || (video && EXAMPLE_CLIP.test(video))) source.adopt(video, video.split("/").pop());
+ const words = q.get("prompt")?.trim();
+ // After the first paint (the page is prerendered with an empty field).
+ if (words)
+ void Promise.resolve().then(() => {
+ setMode("type");
+ setPrompt(words.slice(0, 300));
+ });
// Once, on arrival.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
@@ -573,6 +587,8 @@ export function RemoveObjectTool({ person = false }: { person?: boolean } = {})
)}
</div>
+ {examples && !clip && !run && history.isSuccess && !history.data.length && <ExampleRow row={examples} layout="column" maxColumns={2} maxWidth={640} className="mt-12" />}
+
{run && <RunPanel run={run} onAgain={start} onRedo={(r) => setRun({ ...run, final: r.final.id, ids: r.items.map((g) => g.id) })} />}
{earlier.length > 0 && (
diff --git a/src/components/studio/mode-switch-studio.tsx b/src/components/studio/mode-switch-studio.tsx
index 78f64107..add17073 100644
--- a/src/components/studio/mode-switch-studio.tsx
+++ b/src/components/studio/mode-switch-studio.tsx
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { Suspense } from "react";
import { exampleRow } from "@/lib/examples/catalog";
+import type { ExampleRowData } from "@/lib/examples/types";
import {
AUDIO_STUDIO,
DIALOGUE_STUDIO,
@@ -67,7 +68,7 @@ const CONFIGS: Record<HubKind, Record<string, StudioConfig>> = {
};
/** Modes that are their own tool rather than a composer studio (Translate & dub, Loop / extend, Join, Split soundtrack, Clean up voice, Design a voice, Edit speech, Remove object, Remove dialogue, Evolution, Restore & colourise, Captions, Trim). */
-const TOOLS: Partial<Record<HubKind, Record<string, () => React.ReactNode>>> = {
+const TOOLS: Partial<Record<HubKind, Record<string, (examples: ExampleRowData | null) => React.ReactNode>>> = {
audio: {
translate: () => <DubStudio />,
loop: () => <AudioLoopTool />,
@@ -79,8 +80,8 @@ const TOOLS: Partial<Record<HubKind, Record<string, () => React.ReactNode>>> = {
"edit-speech": () => <SpeechEditTool setup={ownSetupsNow(["audio:edit-speech"])["audio:edit-speech"]} />,
},
"video-tools": {
- "remove-object": () => <RemoveObjectTool />,
- "remove-person": () => <RemoveObjectTool person />,
+ "remove-object": (examples) => <RemoveObjectTool examples={examples} />,
+ "remove-person": (examples) => <RemoveObjectTool person examples={examples} />,
"remove-dialogue": () => <RemoveDialogueTool />,
evolution: () => <EvolutionTool />,
restore: () => <RestoreTool setup={ownSetupsNow(["video-tools:restore"])["video-tools:restore"]} />,
@@ -97,7 +98,8 @@ const TOOLS: Partial<Record<HubKind, Record<string, () => React.ReactNode>>> = {
export function ModeSwitchStudio({ kind, mode }: { kind: HubKind; mode?: string }) {
const current = mode ?? HUB_MODES[kind][0].id;
const Tool = TOOLS[kind]?.[current];
- if (Tool) return <Tool />;
+ // A tool of its own shows its mode's examples, each opening the tool with its clip and words in.
+ if (Tool) return Tool(exampleRow(`hub:${kind}/${current}`));
const config = CONFIGS[kind][current];
if (!config) notFound();
// A composer mode's own examples ("hub:upscale", "hub:upscale/video"…), else the hub's covers that fit it. The hub's