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.

Canvas and Assist: inputs for the round-4 operations

Claude93f22cfd2d82
diff --git a/src/lib/catalog/canvas.ts b/src/lib/catalog/canvas.ts
index 5c3f972c..d077c7ee 100644
--- a/src/lib/catalog/canvas.ts
+++ b/src/lib/catalog/canvas.ts
@@ -258,8 +258,14 @@ export function nodeLabel(n: Pick<CanvasNode, "type" | "data">): string {
// ---------------------------------------------------------------------------
// Models for generator nodes
-/** Ops the canvas can't feed (masks, browser-only tools, multi-speaker scripts, draft finishing). */
-const UNSUPPORTED_OPS = new Set<Operation>(["grade", "inpaint", "finalize", "dialogue"]);
+/**
+ * Ops the canvas can't feed (masks, browser-only tools, multi-speaker scripts, draft finishing, and
+ * inputs it has no port for: a 3D model to rig, a list of audio clips to join).
+ */
+const UNSUPPORTED_OPS = new Set<Operation>(["grade", "inpaint", "finalize", "dialogue", "rig-3d", "audio-join"]);
+
+/** Models that only run on a painted mask or clicked points (VACE inpaint, Bria's point eraser): the canvas has neither. */
+const needsMarks = (m: ModelDef) => !!(m.options.requires?.mask || m.options.requires?.points);
/** Preferred defaults; anything missing falls back to the first catalog model for that op and engine. */
const PREFERRED: Partial<Record<Operation, Partial<Record<Engine, string>>>> = {
@@ -322,10 +328,10 @@ export function defaultModelForNode(n: Pick<CanvasNode, "type" | "data">, engine
export function modelChoices(n: Pick<CanvasNode, "type" | "data">): ModelDef[] {
if (n.type === "model") {
const kind = n.data.mediaKind;
- return MODELS.filter((m) => !m.hidden && (!kind || m.kind === kind) && m.routes.some((r) => !UNSUPPORTED_OPS.has(r.op)));
+ return MODELS.filter((m) => !m.hidden && (!kind || m.kind === kind) && !needsMarks(m) && m.routes.some((r) => !UNSUPPORTED_OPS.has(r.op)));
}
const ops = nodeOps(n);
- return MODELS.filter((m) => ops.some((op) => supportsOp(m, op)) && (!m.hidden || ops.includes("frame")));
+ return MODELS.filter((m) => ops.some((op) => supportsOp(m, op)) && (!m.hidden || ops.includes("frame")) && !needsMarks(m));
}
// ---------------------------------------------------------------------------
@@ -388,10 +394,27 @@ const OP_PORTS: Partial<Record<Operation, InputPortId[]>> = {
"separate-audio": ["audio", "video"],
translate: ["prompt"],
write: ["prompt"],
+ vectorize: ["images"],
+ // round 4 (masks, clicked points and keyframe times are set outside the canvas)
+ "remove-object": ["prompt", "video"],
+ "video-swap": ["prompt", "elements", "video", "images"],
+ "video-insert": ["prompt", "elements", "video", "images"],
+ keyframes: ["prompt", "images"],
+ "sdr-to-hdr": ["video"],
+ "export-video": ["video"],
+ ocr: ["images"],
+ "still-motion": ["images"],
+ "audio-loop": ["audio"],
+ "scene-3d": ["images"],
+ splat: ["images"],
+ "text-to-3d": ["prompt"],
+ "extract-frames": ["video"],
+ "images-to-video": ["images"],
+ overlay: ["images"],
};
/** Ops whose images list takes several images. */
-const MULTI_IMAGE_OPS = new Set<Operation>(["edit", "ref2v", "face-swap", "color-match", "relight-video"]);
+const MULTI_IMAGE_OPS = new Set<Operation>(["edit", "ref2v", "face-swap", "color-match", "relight-video", "video-swap", "video-insert", "keyframes", "images-to-video", "overlay"]);
const TEXT_LABEL_OPS = new Set<Operation>(["tts", "translate", "write", "sfx", "music"]);
diff --git a/src/server/assist/tools.ts b/src/server/assist/tools.ts
index a757c1f4..a32195a8 100644
--- a/src/server/assist/tools.ts
+++ b/src/server/assist/tools.ts
@@ -306,8 +306,11 @@ function toRequest(j: JobInput): GenerationRequest {
function slotFor(kind: MediaKind, op: Operation | undefined): ChainSlot {
if (kind === "text") return { slot: "prompt" };
if (kind === "video") return { slot: op === "concat" ? "videos" : "video" };
- // tts clones the earlier audio's voice; voice-change re-voices the earlier audio (its target voice is voice_audio).
- if (kind === "audio") return { slot: op === "tts" ? "voiceAudio" : "audio" };
+ // tts clones the earlier audio's voice; voice-change re-voices the earlier audio (its target voice is voice_audio);
+ // a join takes it as one of its clips.
+ if (kind === "audio") return { slot: op === "tts" ? "voiceAudio" : op === "audio-join" ? "audios" : "audio" };
+ // A mesh goes on to be rigged.
+ if (kind === "model3d") return { slot: "model3d" };
return { slot: "images", position: "first" };
}
diff --git a/tests/assist-runtime.test.ts b/tests/assist-runtime.test.ts
index 0c6704e3..74e43b64 100644
--- a/tests/assist-runtime.test.ts
+++ b/tests/assist-runtime.test.ts
@@ -216,6 +216,18 @@ describe("new kinds and operations in the tools", () => {
]);
});
+ it("hands a 3D model on to be rigged", () => {
+ const plan = tools.planFor(
+ "generate",
+ { summary: "A knight, rigged", jobs: [{ model_id: "tripo-h3-1-text", prompt: "A knight in plate armour" }, { model_id: "meshy-rigging", op: "rig-3d", prompt: "Rig it", after: 0 }] },
+ { engine: "cloud" },
+ );
+ expect(plan.jobs.map((j) => [j.op, j.error])).toEqual([
+ ["text-to-3d", undefined],
+ ["rig-3d", undefined],
+ ]);
+ });
+
it("passes a background track to mux", async () => {
const out = await tools.executeTool(
"generate",
diff --git a/tests/canvas.test.ts b/tests/canvas.test.ts
index 5a8e102c..1d2ef373 100644
--- a/tests/canvas.test.ts
+++ b/tests/canvas.test.ts
@@ -11,6 +11,7 @@ import {
graphEngine,
inputPorts,
isGenerator,
+ modelChoices,
nodeSignature,
outputType,
paletteItems,
@@ -24,7 +25,7 @@ import {
type CanvasNode,
type CanvasRuns,
} from "@/lib/catalog/canvas";
-import type { GenerationStatus } from "@/lib/catalog/types";
+import type { GenerationStatus, Operation } from "@/lib/catalog/types";
const node = (id: string, type: CanvasNode["type"], x: number, y: number, data: CanvasNode["data"] = {}): CanvasNode => ({ id, type, position: { x, y }, data });
const edge = (source: string, target: string, targetHandle = "in"): CanvasEdge => ({ id: `${source}>${target}:${targetHandle}`, source, sourceHandle: "out", target, targetHandle });
@@ -399,3 +400,43 @@ describe("canvas templates", () => {
expect(describeNode({ nodes: [frame], edges: [] }, frame).error).toBe("Pick a model");
});
});
+
+describe("round-4 models on the canvas", () => {
+ const modelNode = (modelId: string, op?: Operation): CanvasNode => node("m", "model", 300, 0, { modelId, mediaKind: getModel(modelId)!.kind, ...(op && { op }) });
+ const ports = (id: string, op?: Operation) => inputPorts(modelNode(id, op)).map((p) => p.id);
+
+ it("gives the new operations their inputs", () => {
+ expect(ports("kling-o3", "remove-object")).toEqual(["prompt", "video"]);
+ expect(ports("kling-o3", "video-swap")).toEqual(["prompt", "elements", "images", "video"]);
+ expect(ports("bria-video-erase")).toEqual(["prompt", "video"]);
+ expect(ports("p-video-replace")).toEqual(["prompt", "elements", "images", "video"]);
+ expect(ports("genjutsu-lite-object-swap")).toEqual(["prompt", "elements", "images", "video"]);
+ expect(ports("florence-2-ocr")).toEqual(["images"]);
+ expect(ports("topaz-sdr-to-hdr")).toEqual(["video"]);
+ expect(ports("triposplat")).toEqual(["images"]);
+ expect(ports("tripo-h3-1-text")).toEqual(["prompt"]);
+ expect(ports("recraft-vectorize")).toEqual(["images"]);
+ const keyframes = inputPorts(modelNode("flux-3-max", "keyframes"));
+ expect(keyframes.map((p) => p.id)).toEqual(["prompt", "images"]);
+ expect(keyframes.find((p) => p.id === "images")!.multiple).toBe(true);
+ });
+
+ it("runs an eraser fed from the board", () => {
+ const g: CanvasGraph = {
+ nodes: [node("clip", "video-input", 0, 0, { url: "/api/files/clip.mp4" }), node("m", "model", 300, 0, { modelId: "bria-video-erase", prompt: "the coffee cup" })],
+ edges: [edge("clip", "m", "video")],
+ };
+ const d = describeNode(g, g.nodes[1]);
+ expect(d.error).toBeUndefined();
+ expect(d.plan?.op).toBe("remove-object");
+ });
+
+ it("leaves out models and operations the canvas can't feed", () => {
+ const video = modelChoices({ type: "model", data: { mediaKind: "video" } }).map((m) => m.id);
+ expect(video).toContain("bria-video-erase");
+ // VACE runs only on a painted first-frame mask.
+ expect(video).not.toContain("wan-22-vace-inpaint");
+ // Rigging needs a 3D model input, which the canvas has no port for.
+ expect(modelChoices({ type: "model", data: { mediaKind: "model3d" } }).map((m) => m.id)).not.toContain("meshy-rigging");
+ });
+});