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
Video: the browser knows which routes take an end frame alone
Adarsh794fe1c5a19d
diff --git a/scripts/gen-cloud-models.py b/scripts/gen-cloud-models.pyindex 91719624..f7af70a1 100644--- a/scripts/gen-cloud-models.py+++ b/scripts/gen-cloud-models.py@@ -611,7 +611,7 @@ model("wan-2-5", "Wan 2.5", "Alibaba Wan", "wan", "video", "Audio-driven video u[("t2v", "fal-ai/wan-25-preview/text-to-video"), ("i2v", "fal-ai/wan-25-preview/image-to-video")],badges=["audio"], pricing=("second", 0.15, "1080p"), defaults={"aspectRatio": "16:9", "duration": 5, "resolution": "1080p"})# fal's H3, H3 Max and H3 Max Turbo image to video take an end frame alone ("It may be provided alone for end-only keyframe-# generation; in that case the output canvas follows this image"): FieldMap.endAlone, so a run with only an end frame goes there.+# generation; in that case the output canvas follows this image"): ModelRoute.endAlone, so a run with only an end frame goes there.END_ALONE = {"flf2v": True, "endAlone": True}# Hosted MiniMax H3 makes its own sound. fal takes a whole number of seconds from 5 to 15 and bills each second by the# resolution (its pricing record, docs/research/new-models-7.json): 480P $0.05, 768P $0.06, 2K $0.13, 4K $0.16. Without@@ -2638,15 +2638,15 @@ def build_route(op, ep, provider, m, opts, ropts=None):# FieldMap.publicLinks, so the server sends each file as a public https link, never a data: URI or a Files API link.if ropts.get("publicLinks"):fmap["publicLinks"] = True- # An end frame the endpoint takes without a start frame (FieldMap.endAlone).+ route = {"op": op, "provider": provider, "endpoint": f"{ep}:{version}" if ropts.get("pin") else ep, "map": fmap}+ if ropts.get("note"):+ route["note"] = ropts["note"]+ # An end frame the endpoint takes without a start frame (ModelRoute.endAlone, kept in the browser's slimmed catalog).if ropts.get("endAlone"):if "endImage" in fmap:- fmap["endAlone"] = True+ route["endAlone"] = Trueelse:warn(f"{m['id']}: {ep} has no end frame field; no endAlone")- route = {"op": op, "provider": provider, "endpoint": f"{ep}:{version}" if ropts.get("pin") else ep, "map": fmap}- if ropts.get("note"):- route["note"] = ropts["note"]# The most stills this route reads (ModelRoute.maxImages): set on every route of an op, the plan refuses more.if ropts.get("route_max_images"):route["maxImages"] = ropts["route_max_images"]diff --git a/src/lib/catalog/cloud-models.generated.ts b/src/lib/catalog/cloud-models.generated.tsindex b09f1605..4f063d40 100644--- a/src/lib/catalog/cloud-models.generated.ts+++ b/src/lib/catalog/cloud-models.generated.ts@@ -8299,9 +8299,9 @@ export const CLOUD_MODELS: ModelDef[] = ["key": "duration","type": "number"},- "promptMax": 50000,- "endAlone": true- }+ "promptMax": 50000+ },+ "endAlone": true},{"op": "flf2v",@@ -8316,9 +8316,9 @@ export const CLOUD_MODELS: ModelDef[] = ["key": "duration","type": "number"},- "promptMax": 50000,- "endAlone": true- }+ "promptMax": 50000+ },+ "endAlone": true},{"op": "ref2v",@@ -8458,9 +8458,9 @@ export const CLOUD_MODELS: ModelDef[] = ["defaults": {"prompt_expansion_mode": "balanced"},- "promptMax": 50000,- "endAlone": true- }+ "promptMax": 50000+ },+ "endAlone": true},{"op": "flf2v",@@ -8485,9 +8485,9 @@ export const CLOUD_MODELS: ModelDef[] = ["defaults": {"prompt_expansion_mode": "balanced"},- "promptMax": 50000,- "endAlone": true- }+ "promptMax": 50000+ },+ "endAlone": true},{"op": "ref2v",@@ -9568,9 +9568,9 @@ export const CLOUD_MODELS: ModelDef[] = ["defaults": {"prompt_expansion_mode": "balanced"},- "promptMax": 50000,- "endAlone": true- }+ "promptMax": 50000+ },+ "endAlone": true},{"op": "flf2v",@@ -9595,9 +9595,9 @@ export const CLOUD_MODELS: ModelDef[] = ["defaults": {"prompt_expansion_mode": "balanced"},- "promptMax": 50000,- "endAlone": true- }+ "promptMax": 50000+ },+ "endAlone": true}],"options": {diff --git a/src/lib/catalog/plan.ts b/src/lib/catalog/plan.tsindex 7763f9e9..85a2c4c6 100644--- a/src/lib/catalog/plan.ts+++ b/src/lib/catalog/plan.ts@@ -82,10 +82,10 @@ export function inferOperation(model: ModelDef, req: Pick<GenerationRequest, "opreturn model.routes[0].op;}-/** Every start-and-end route of the model takes the end frame without a start frame (FieldMap.endAlone: fal's H3 family). */+/** Every start-and-end route of the model takes the end frame without a start frame (ModelRoute.endAlone: fal's H3 family). */export function takesEndAlone(model: Pick<ModelDef, "routes">): boolean {const routes = model.routes.filter((r) => r.op === "flf2v");- return routes.length > 0 && routes.every((r) => !!r.map?.endAlone);+ return routes.length > 0 && routes.every((r) => !!r.endAlone);}/**@@ -1088,7 +1088,7 @@ export function missingInputs(op: Operation, req: Pick<GenerationRequest, "inputconst n = NEEDS[op];if (!n) return null;const i = req.inputs ?? {};- // A start-and-end run with only the end frame, on routes that take it alone (FieldMap.endAlone).+ // A start-and-end run with only the end frame, on routes that take it alone (ModelRoute.endAlone).const endAlone = op === "flf2v" && !!i.endImage && !i.images?.length && !!model && takesEndAlone(model);if (n.images && (i.images?.length ?? 0) < n.images && !endAlone) return n.msg;if (n.video && !i.video) return n.msg;diff --git a/src/lib/catalog/types.ts b/src/lib/catalog/types.tsindex 440164d3..d7f10a69 100644--- a/src/lib/catalog/types.ts+++ b/src/lib/catalog/types.ts@@ -391,12 +391,6 @@ export interface FieldMap {/** Array of images field, e.g. "image_urls" (receives every reference image). */images?: string;endImage?: string;- /**- * The endpoint takes the end frame without a start frame (fal's H3, H3 Max and H3 Max Turbo image to video: "It may be- * provided alone"; the clip then takes the end frame's shape). A run with only an end frame goes to its start-and-end- * route; on a model without it, the end frame needs a start frame (endFrameAloneProblem in plan.ts).- */- endAlone?: boolean;mask?: string;/** What the mask's paint means to this API: white (default), black or transparent = change. */maskFormat?: "white" | "black" | "alpha";@@ -672,6 +666,13 @@ export interface ModelRoute {/** fal endpoint id, replicate "owner/name", or ComfyUI workflow id from the manifest. */endpoint: string;map?: FieldMap;+ /**+ * The endpoint takes the end frame without a start frame (fal's H3, H3 Max and H3 Max Turbo image to video: "It may be+ * provided alone"; the clip then takes the end frame's shape). A run with only an end frame goes to its start-and-end+ * route; on a model without it, the end frame needs a start frame (endFrameAloneProblem in plan.ts).+ * A route field, not a map field, so the browser's slimmed catalog (slimModel) keeps it.+ */+ endAlone?: boolean;/*** The parts of `map` the composer previews a result with ("1920×1080 → 2880×1620", an EXR frame count, the canvas a* layout is compiled at), kept by slimModel when it drops the field maps for the browser. The server reads `map`.diff --git a/tests/end-frame-alone.test.ts b/tests/end-frame-alone.test.tsindex a2f4b421..c8a46933 100644--- a/tests/end-frame-alone.test.ts+++ b/tests/end-frame-alone.test.ts@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";import { getModel, getPreset, MODELS } from "@/lib/catalog";import { endFrameAloneProblem, inferOperation, planGeneration, routesFor, takesEndAlone } from "@/lib/catalog/plan";import type { GenerationRequest } from "@/lib/catalog/types";+import { slimModel } from "@/lib/studio-catalog";import { bodyProblems, END, handOverInput, IMG, inputSchema, PROMPT, routeRequest, SCHEMA_INDEX } from "./helpers/provider-schemas";/**@@ -43,6 +44,19 @@ describe("an end frame alone on fal's H3 family", () => {}});+ it("the browser's slimmed catalog (no field maps) plans it the same, with nothing said", () => {+ for (const id of H3_FAMILY) {+ const slim = slimModel(getModel(id)!);+ expect(slim.routes.every((r) => !r.map), id).toBe(true);+ expect(takesEndAlone(slim), id).toBe(true);+ expect(inferOperation(slim, { inputs: { endImage: END } }), id).toBe("flf2v");+ expect(endFrameAloneProblem(slim, { endImage: END }), id).toBeNull();+ const p = planGeneration({ feature: "video", modelId: id, prompt: PROMPT, inputs: { endImage: END }, params: {} }, (m) => (m === id ? slim : getModel(m)), getPreset);+ expect(p.op, id).toBe("flf2v");+ }+ expect(endFrameAloneProblem(slimModel(getModel("minimax-h3-lite")!), { endImage: END })).toMatch(/only after a start frame/);+ });+it("an API caller's start-and-end op with only the end frame runs too", () => {expect(plan("minimax-h3-max-turbo", { endImage: END }, "flf2v").op).toBe("flf2v");});@@ -59,8 +73,8 @@ describe("an end frame alone on fal's H3 family", () => {});});-describe("conformance: a route that takes an end frame alone (FieldMap.endAlone)", () => {- const flagged = MODELS.flatMap((m) => m.routes.filter((r) => r.map?.endAlone).map((r) => ({ id: m.id, route: r })));+describe("conformance: a route that takes an end frame alone (ModelRoute.endAlone)", () => {+ const flagged = MODELS.flatMap((m) => m.routes.filter((r) => r.endAlone).map((r) => ({ id: m.id, route: r })));it("is fal's H3 family's image to video, and nothing else", () => {expect([...new Set(flagged.map((f) => f.route.endpoint))].sort()).toEqual(["minimax/h3-max-turbo/image-to-video", "minimax/h3-max/image-to-video", "minimax/h3/image-to-video"]);