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
Originals O11: Angles keeps its 2511 default next to Fuobe Angles; Speak priced and rendered for the whole voice; the cloud face mosaic made on the server
Claude9191861c49f2
diff --git a/docs/research/fuobe-originals-recipes-5.json b/docs/research/fuobe-originals-recipes-5.jsonindex 79af336d..e07533ad 100644--- a/docs/research/fuobe-originals-recipes-5.json+++ b/docs/research/fuobe-originals-recipes-5.json@@ -12065,7 +12065,7 @@"notes": "Do the pixelation in post: SAM 3.1 face mask, then a mosaic filter on the masked area.","checked": "2026-10-23","post": "face-mosaic",- "postNote": "Added 2026-10-29 (o/o11-open-tools): the pixelation is a step after the picture: SAM 3.1 finds the faces, a mosaic covers them (open: image-face-mosaic-sam3; cloud: fal-ai/sam-3-1/image's mask, pixelated in the browser)."+ "postNote": "Added 2026-10-29 (o/o11-open-tools): the pixelation is a step after the picture: SAM 3.1 finds the faces, a mosaic covers them (open: image-face-mosaic-sam3; cloud: fal-ai/sam-3-1/image's masks, pixelated by the server, or the browser for a picture it can't decode)."},{"id": "255f4045-d68b-42b1-9e4c-f49d3263a9d7",@@ -18663,7 +18663,7 @@{"id": "angles","higgsfield": "Higgsfield Angles (job QWEN_CAMERA_CONTROL: rotate_degree, move_forward_level, vertical_angle, sample_steps, loras lightx + camera_angle)",- "open": "Qwen-Image-Edit 2509 + dx8152 Multiple-angles LoRA (1.25) + Qwen-Image-Lightning (Fuobe qwen-image-edit-2509-angles); Qwen-Image-Edit 2511 + fal's Multiple-Angles LoRA stays for Cinema's recomposition and Soul Location's views",+ "open": "Qwen-Image-Edit 2509 + dx8152 Multiple-angles LoRA (1.25) + Qwen-Image-Lightning (Fuobe qwen-image-edit-2509-angles); Qwen-Image-Edit 2511 + fal's Multiple-Angles LoRA stays the Angles app's default (with fal's Qwen Multiple Angles in the cloud) until the angles eval suite (scripts/eval/cases/angles.json) promotes Fuobe Angles, which is its own app next to it, and stays for Cinema's recomposition and Soul Location's views","hosted": ["fal-ai/qwen-image-edit-2509-lora-gallery/multiple-angles ($0.035 per megapixel; rotate_right_left −90…90 (positive = left), vertical_angle −1…1 (−1 bird's-eye, 1 worm's-eye), move_forward 0–10, wide_angle_lens, lora_scale 1.25, 6 steps; no prompt field)"],@@ -23428,7 +23428,7 @@"prompt": "prompt","image": "image_url"},- "output": "video.url",+ "output": "masks[].url","price": "Your request will cost $0.01 per request.","verified": true,"schemaUrl": "https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/sam-3-1/image",diff --git a/scripts/eval/cases/angles.json b/scripts/eval/cases/angles.jsonnew file mode 100644index 00000000..b4060d14--- /dev/null+++ b/scripts/eval/cases/angles.json@@ -0,0 +1,50 @@+{+ "$schema": "./case.schema.json",+ "suite": "angles",+ "title": "Fuobe Angles · the same shot from another camera",+ "description": "A photo you supply (local/angles/subject.png: a person or a product in a scene) seen from another camera. Measures identity against the photo, CLIP and aesthetic. Fuobe Angles (O11) is Higgsfield Angles' recipe: Qwen-Image-Edit 2509 with dx8152's Multiple-angles LoRA (on your GPU with Qwen-Image-Lightning, the camera written as the LoRA's own words; in the cloud fal's 2509 multiple-angles route at LoRA strength 1.25, 6 steps). The Angles app stays on today's 2511 recipe (Qwen-Image-Edit 2511 + fal's Multiple-Angles LoRA on your GPU, fal's Qwen Multiple Angles in the cloud) until this suite promotes Fuobe Angles; the today variants run it on the same photo and camera. The prompts are Fuobe's own.",+ "original": "fuobe-angles",+ "kind": "image",+ "targets": {+ "open": { "models": ["fuobe-angles"] },+ "cloud": { "models": ["fuobe-angles"] },+ "demo": { "models": ["fuobe-angles"] }+ },+ "defaults": { "seeds": [1001, 2002], "metrics": ["identity", "clip", "aesthetic"], "timeoutSeconds": 1800, "candidate": "recipe" },+ "variants": {+ "recipe": {+ "description": "Fuobe Angles: the camera turned 45° to the left (fal's rotate_right_left; the LoRA's words on your GPU)",+ "extra": { "rotate_right_left": 45 }+ },+ "today-open": {+ "description": "The Angles app's GPU route today: Qwen-Image-Edit 2511 + fal's Multiple-Angles LoRA, its <sks> words for the same view",+ "engines": ["open"],+ "models": { "open": ["oss-qwen-edit"] },+ "loras": [+ {+ "file": "qwen-image-edit-2511-multiple-angles-lora.safetensors",+ "url": "https://huggingface.co/fal/Qwen-Image-Edit-2511-Multiple-Angles-LoRA/resolve/main/qwen-image-edit-2511-multiple-angles-lora.safetensors",+ "strength": 1+ }+ ],+ "words": "<sks> front-left quarter view eye-level shot medium shot."+ },+ "today-cloud": {+ "description": "The Angles app's cloud route today: fal's Qwen Multiple Angles (2511) at the same view",+ "engines": ["cloud"],+ "models": { "cloud": ["qwen-multiple-angles"] },+ "extra": { "horizontal_angle": 315, "vertical_angle": 0, "zoom": 5 }+ }+ },+ "cases": [+ {+ "id": "angles/turn-left",+ "title": "The same shot with the camera turned 45° to the left",+ "op": "edit",+ "inputs": { "images": ["local/angles/subject.png"] },+ "demoInputs": { "images": ["fixtures/start-frame.png"] },+ "references": "local/angles/subject.png",+ "prompts": [{ "id": "keep", "text": "Keep the same subject, identity, outfit, lighting and environment" }]+ }+ ]+}diff --git a/scripts/fetch-hosted-schemas.py b/scripts/fetch-hosted-schemas.pyindex 22b0ca96..eb332414 100644--- a/scripts/fetch-hosted-schemas.py+++ b/scripts/fetch-hosted-schemas.py@@ -259,6 +259,10 @@ def fal_prices(endpoint):return "; ".join(dict.fromkeys(lines[:6])) or None+# What an answer holds when it's neither pictures (t2i, edit) nor a video: SAM 3.1's face masks (the face mosaic).+OUTPUT_OF = {"face-mosaic": "masks[].url"}++def base_record(ep, op, kf, price=None):inputs = fal(ep)missing = [f for f in kf.values() if f not in inputs]@@ -266,7 +270,7 @@ def base_record(ep, op, kf, price=None):sys.exit(f"{ep}: keyFields {missing} are not inputs")print(f"{ep}: {len(inputs)} inputs")return {"provider": "fal", "endpoint": ep, "operation": op, "status": "active", "inputs": inputs, "keyFields": kf,- "output": "images[].url" if op in ("t2i", "edit") else "video.url", "price": price if price is not None else fal_price(ep), "verified": True,+ "output": OUTPUT_OF.get(op) or ("images[].url" if op in ("t2i", "edit") else "video.url"), "price": price if price is not None else fal_price(ep), "verified": True,"schemaUrl": f"https://fal.ai/api/openapi/queue/openapi.json?endpoint_id={ep}", "checked": TODAY}diff --git a/scripts/gen-cloud-models.py b/scripts/gen-cloud-models.pyindex f5d8f0d4..492e91e3 100644--- a/scripts/gen-cloud-models.py+++ b/scripts/gen-cloud-models.py@@ -658,9 +658,9 @@ model("fuobe-speak-motion", "Fuobe Speak · Motion", "Fuobe Original", "fuobe-sp{"byResolution": {"480p": 0.1, "580p": 0.15, "720p": 0.2}}),defaults={"resolution": "480p"})# The face mosaic's cloud step (Fuobe Soul's PixeletedFace look): SAM 3.1 finds every face and answers with their masks;-# the browser pixelates under them. A helper step, not a picker model.+# Fuobe pixelates under them (the server, or the browser for a picture it can't decode). A helper step, not a picker model.model("sam-3-1-face-mask", "SAM 3.1 face mask", "Meta", "sam", "image",- "Finds the faces (or what you name) in a picture; the browser pixelates them",+ "Finds the faces (or what you name) in a picture; Fuobe pixelates them",[("face-mosaic", "fal-ai/sam-3-1/image")], hidden=True, pricing=("request", 0.01),fixed={"apply_mask": False, "return_multiple_masks": True, "max_masks": 16, "output_format": "png"}, api_defaults={"prompt": "face"})model("ltx-2-5", "LTX 2.5 Pro", "Lightricks", "ltx", "video", "Fast 4K-capable video with audio",diff --git a/src/components/studio/composer.tsx b/src/components/studio/composer.tsxindex 6d0a0117..05b71587 100644--- a/src/components/studio/composer.tsx+++ b/src/components/studio/composer.tsx@@ -223,9 +223,18 @@ export function Composer({ docked }: { docked: boolean }) {// Upscale hub: the attached clip's header (length, size, frame rate). Its length prices per-second tools and// travels with the request (params.sourceDuration); a clip swapped since a Reuse never keeps the old one's.const facts = useClipFacts(config.clipFacts && !typed.slots.video?.uploading ? typed.slots.video?.ref : undefined).data;+ // Lipsync: a talking avatar is as long as its voice (the voice's header prices it and goes with the request); not while a+ // video is attached (lip re-sync keeps the clip's length).+ const voiceRef = config.voiceFacts && !typed.slots.video?.ref && !typed.slots.audio?.uploading ? typed.slots.audio?.ref : undefined;+ const voice = useClipFacts(voiceRef).data;const draft = useMemo(- () => (config.clipFacts ? { ...typed, params: { ...typed.params, sourceDuration: typed.slots.video?.ref ? facts?.duration : undefined } } : typed),- [config.clipFacts, typed, facts?.duration],+ () =>+ config.clipFacts+ ? { ...typed, params: { ...typed.params, sourceDuration: typed.slots.video?.ref ? facts?.duration : undefined } }+ : config.voiceFacts+ ? { ...typed, params: { ...typed.params, sourceDuration: voiceRef ? voice?.duration : undefined } }+ : typed,+ [config.clipFacts, config.voiceFacts, typed, facts?.duration, voiceRef, voice?.duration],);const liveElements = useElements().data;const elements = (hydrated && liveElements) || EMPTY;diff --git a/src/components/studio/studio-context.tsx b/src/components/studio/studio-context.tsxindex 3b4cdb2b..177ab82c 100644--- a/src/components/studio/studio-context.tsx+++ b/src/components/studio/studio-context.tsx@@ -58,6 +58,11 @@ export interface StudioConfig {* says what comes out ("24 → 60 fps", "1280×720 → 3840×2160"). Upscale hub video modes.*/clipFacts?: boolean;+ /**+ * Read the voice track's length (Lipsync): a talking avatar is as long as its voice, so a per-second price counts its+ * seconds and the request carries them (params.sourceDuration). Not while a video is attached (lip re-sync).+ */+ voiceFacts?: boolean;/** Offer every output format of the studio's models on this engine; picking one another model writes moves the request there (SDR to HDR, Export). */formatPicker?: boolean;/** The models' enum settings chip ("Director" by default; "Options" for a tool's settings such as Topaz's model). */diff --git a/src/lib/catalog/apps.ts b/src/lib/catalog/apps.tsindex a3e07a34..6205f5f8 100644--- a/src/lib/catalog/apps.ts+++ b/src/lib/catalog/apps.ts@@ -1,3 +1,4 @@+import { ANGLES_2511_LORA } from "./open-tools";import { CAST_LOOK } from "./soul-cards";import type { InputSlot, Preset, PresetOption, PresetRoute } from "./types";@@ -262,9 +263,58 @@ export const APPS: Preset[] = [icon: "Rotate3d",hue: 190,badges: ["top"],- // Fuobe Angles (O11): Higgsfield Angles' recipe, Qwen-Image-Edit 2509 + dx8152's Multiple-angles LoRA on both engines. The- // choices set the hosted route's own fields (rotate −90…90°, positive = left; vertical −1 above … 1 below; move forward- // 0–10; a wide-angle lens); on the GPU they become the LoRA's words (src/lib/catalog/open-tools.ts). The default turns it.+ // The cloud model turns its rotate / tilt / zoom settings into the Multiple-Angles LoRA's own words; the open+ // route runs that LoRA on Qwen-Image-Edit 2511 with the same words ("<sks> front-left quarter view …"). Fuobe Angles+ // (the next app, O11) is Higgsfield Angles' 2509 recipe; it replaces this default only when the angles eval suite+ // (scripts/eval/cases/angles.json) promotes it.+ options: [+ angleOption("angle", "Angle", "horizontal_angle", [+ ["Front", "front view", 0],+ ["Front right", "front-right quarter view", 45],+ ["Right side", "right side view", 90],+ ["Back right", "back-right quarter view", 135],+ ["Back", "back view", 180],+ ["Back left", "back-left quarter view", 225],+ ["Left side", "left side view", 270],+ ["Front left", "front-left quarter view", 315],+ ]),+ angleOption("height", "Height", "vertical_angle", [+ ["Eye level", "eye-level shot", 0],+ ["Low angle", "low-angle shot", -30],+ ["Elevated", "elevated shot", 30],+ ["High angle", "high-angle shot", 60],+ ]),+ angleOption("distance", "Distance", "zoom", [+ ["Medium", "medium shot", 5],+ ["Close-up", "close-up", 10],+ ["Wide", "wide shot", 0],+ ]),+ ],+ userPrompt: "optional",+ placeholder: "Anything to keep in mind (optional)",+ prompt: "Show the exact same scene and subject as a {option:angle}, {option:height}, {option:distance}, as if the camera physically moved. Keep identity, outfit, props, lighting and environment consistent. {prompt}",+ // fal builds the camera words from the sliders; this goes in as its additional_prompt (never empty, so the+ // app runs without a note).+ cloud: { modelId: "qwen-multiple-angles", op: "edit", promptTemplate: "Keep the same subject, identity, outfit, lighting and environment. {prompt}" },+ open: {+ modelId: "oss-qwen-edit",+ op: "edit",+ loras: [ANGLES_2511_LORA],+ promptTemplate: "<sks> {option:angle} {option:height} {option:distance}. {prompt}",+ },+ parity: "Both engines run the same Multiple-Angles LoRA: hosted by fal on the cloud, added to Qwen-Image-Edit 2511 on the open engine (0.3 GB)",+ }),+ app({+ name: "Fuobe Angles",+ category: "Camera",+ description: "Turn the camera on the same shot: rotate, tilt, move closer, go wide",+ icon: "Rotate3d",+ hue: 205,+ badges: ["new", "beta"],+ // Fuobe Angles (O11): Higgsfield Angles' recipe, Qwen-Image-Edit 2509 + dx8152's Multiple-angles LoRA on both engines, next+ // to the Angles app's 2511 route (which stays the default until the angles eval suite promotes this one). The choices set+ // the hosted route's own fields (rotate −90…90°, positive = left; vertical −1 above … 1 below; move forward 0–10; a+ // wide-angle lens); on the GPU they become the LoRA's words (src/lib/catalog/open-tools.ts). The default turns it.options: [{...angleOption("rotate", "Rotate", "rotate_right_left", [@@ -301,7 +351,7 @@ export const APPS: Preset[] = [cloud: { modelId: "fuobe-angles", op: "edit" },open: { modelId: "fuobe-angles", op: "edit" },parity:- "Both engines run Higgsfield Angles' recipe, Qwen-Image-Edit 2509 + the Multiple-angles LoRA: hosted on fal, or with Qwen-Image-Lightning on your GPU (24 GB). fal's route takes no words of its own",+ "Both engines run Higgsfield Angles' recipe, Qwen-Image-Edit 2509 + the Multiple-angles LoRA: hosted on fal, or with Qwen-Image-Lightning on your GPU (24 GB). fal's route takes no words of its own. Not yet measured: the Angles app stays the default until the angles evaluation suite promotes this recipe",}),app({name: "Shots",diff --git a/src/lib/catalog/cloud-models.generated.ts b/src/lib/catalog/cloud-models.generated.tsindex 02c6c37f..0d3b258d 100644--- a/src/lib/catalog/cloud-models.generated.ts+++ b/src/lib/catalog/cloud-models.generated.ts@@ -7028,7 +7028,7 @@ export const CLOUD_MODELS: ModelDef[] = ["family": "sam","engine": "cloud","kind": "image",- "tagline": "Finds the faces (or what you name) in a picture; the browser pixelates them",+ "tagline": "Finds the faces (or what you name) in a picture; Fuobe pixelates them","routes": [{"op": "face-mosaic",diff --git a/src/lib/catalog/models.ts b/src/lib/catalog/models.tsindex 02489792..464385bc 100644--- a/src/lib/catalog/models.ts+++ b/src/lib/catalog/models.ts@@ -1790,7 +1790,7 @@ const originals: ModelDef[] = [{...original({id: "fuobe-speak",- open: [{ ...comfy("avatar", "infinitetalk-wanwrapper", "InfiniteTalk + FusioniX, 25 steps, shift 10, guidance 5 / 5, 15 motion frames"), extra: { ...SPEAK_GRAPH } }],+ open: [{ ...comfy("avatar", "infinitetalk-wanwrapper", "InfiniteTalk + FusioniX, 25 steps, shift 10, guidance 5 / 5, 15 motion frames"), extra: { ...SPEAK_GRAPH }, loraSlot: true }],tagline: "A portrait speaks your voice track, lips, face and head in sync, long takes · InfiniteTalk + FusioniX free on your GPU (16 GB), or hosted on fal",options: { resolutions: ["480p", "720p"], seed: true, maxImages: 1, promptOptional: true, defaultPrompt: SPEAK_PROMPT },}),@@ -1815,7 +1815,7 @@ const originals: ModelDef[] = [/*** Fuobe Soul's face mosaic on the GPU (build plan O11): SAM 3.1 finds the faces (or what the words name) and a block* mosaic covers them, in one graph. A helper step after a look that asks for it (PixeletedFace); in the cloud fal's- * SAM 3.1 makes the masks and the browser pixelates (sam-3-1-face-mask).+ * SAM 3.1 makes the masks and Fuobe pixelates under them (sam-3-1-face-mask).*/const faceMosaic: ModelDef = o({id: "oss-face-mosaic",diff --git a/src/lib/catalog/open-tools.ts b/src/lib/catalog/open-tools.tsindex 9ea0fa28..8a2f7534 100644--- a/src/lib/catalog/open-tools.ts+++ b/src/lib/catalog/open-tools.ts@@ -10,7 +10,8 @@* frames, 25 steps, shift 10, text and audio guidance 5, colour correction), fal's InfiniteTalk in the cloud.* Fuobe Speak · Motion is Wan 2.2 S2V on both engines (a Speak v1-like route: the body and the scene move).* - The face mosaic (Fuobe Soul's PixeletedFace look): SAM 3.1 finds the faces, a mosaic covers them. On the GPU one- * graph does both; in the cloud fal's SAM 3.1 answers with the masks and the browser pixelates under them.+ * graph does both; in the cloud fal's SAM 3.1 answers with the masks and the server pixelates under them (the browser,+ * for a picture the server can't decode).*/import { loraEntry, loraRef } from "./loras";import type { Engine, LoraRef } from "./types";@@ -24,8 +25,9 @@ const ANGLES_ENTRY = loraEntry("qwen-edit-2509-multiple-angles");export const ANGLES_LORA: LoraRef | undefined = ANGLES_ENTRY && loraRef(ANGLES_ENTRY);/**- * fal's Multiple-Angles LoRA for Qwen-Image-Edit 2511 (its `<sks>` pose words), which Cinema's recomposition and Soul- * Location's other views run on the GPU next to Fuobe Angles' 2509 recipe (the Angles app's open route until O11).+ * fal's Multiple-Angles LoRA for Qwen-Image-Edit 2511 (its `<sks>` pose words): the Angles app's open route, Cinema's+ * recomposition and Soul Location's other views on the GPU, next to Fuobe Angles' 2509 recipe (its own app until the angles+ * eval suite promotes it).*/export const ANGLES_2511_LORA: LoraRef = {file: "qwen-image-edit-2511-multiple-angles-lora.safetensors",diff --git a/src/lib/catalog/payload.ts b/src/lib/catalog/payload.tsindex 86810d83..94eba0a8 100644--- a/src/lib/catalog/payload.ts+++ b/src/lib/catalog/payload.ts@@ -857,15 +857,18 @@ function matteOutputs(response: unknown): ExtractedOutput[] {}/**- * Pixelate faces on the cloud (fal's SAM 3.1 image): the answer is masks, not the picture. The first mask is the- * result and every mask rides along (meta.masks, white = a face), so the browser pixelates under all of them- * (src/lib/soul-post.ts). No mask: nothing was found, which is no result.+ * Pixelate faces on the cloud (fal's SAM 3.1 image): the answer is masks, not the picture. One answer carries every mask+ * (meta.masks, white = a face): the server pixelates the picture SAM looked at under all of them (src/server/generations.ts+ * mosaicOutput). An answer that found no face (an empty masks list) is still an answer, with no masks: the picture stays+ * as it is, as on the GPU. Anything else is no result.*/function faceMaskOutputs(response: unknown): ExtractedOutput[] {const r = body(response);- const masks = isObj(r) && Array.isArray(r.masks) ? r.masks.map(fileOf).filter((f): f is NonNullable<ReturnType<typeof fileOf>> => !!f) : [];- const all = masks.length ? masks : isObj(r) && fileOf(r.image) ? [fileOf(r.image)!] : [];- if (!all.length) return [];+ if (!isObj(r)) return [];+ const masks = Array.isArray(r.masks) ? r.masks.map(fileOf).filter((f): f is NonNullable<ReturnType<typeof fileOf>> => !!f) : [];+ // Without a masks list, the mask preview (`image`) is the one mask.+ const all = Array.isArray(r.masks) ? masks : fileOf(r.image) ? [fileOf(r.image)!] : [];+ if (!all.length) return Array.isArray(r.masks) ? [{ url: "", kind: "image", meta: { role: "mask", masks: [] } }] : [];return [{ url: all[0].url, kind: "image", contentType: all[0].contentType, meta: { role: "mask", masks: all.map((m) => m.url) } }];}diff --git a/src/lib/catalog/plan.ts b/src/lib/catalog/plan.tsindex 61f15551..8c24ce22 100644--- a/src/lib/catalog/plan.ts+++ b/src/lib/catalog/plan.ts@@ -261,7 +261,7 @@ export function planGeneration(notes.push(...r.notes);// PixeletedFace: a second step pixelates the faces (src/server/chains.ts createMosaicRun).if (r.look?.post === "face-mosaic") {- notes.push(model.engine === "open" ? "Then SAM 3.1 pixelates the faces on your GPU (free)" : `Then SAM 3.1 finds the faces (${"$"}0.01 a picture) and they're pixelated as the picture arrives`);+ notes.push(model.engine === "open" ? "Then SAM 3.1 pixelates the faces on your GPU (free)" : `Then fal's SAM 3.1 finds the faces (${"$"}0.01 a picture) and they're pixelated`);}const own = new Set(req.loras ?? []);soulPlan = {@@ -604,6 +604,17 @@ export function pricingAt(p: Pricing, now = Date.now()): Pricing {*/const CLIP_LENGTH_OPS = new Set<Operation>(["upscale-video", "interpolate", "sdr-to-hdr", "export-video"]);+/**+ * The seconds a talking avatar is made (and billed) for a voice `seconds` long: as long as the voice, or what a+ * frame-count route's limits make of it, in the seconds it bills (fal's InfiniteTalk: 41–721 frames, 25 a second; Wan 2.2+ * S2V: 40–120 frames, a video second being 16 of them at any frame rate).+ */+export function avatarSeconds(model: Pick<ModelDef, "routes">, seconds: number, fps?: number): number {+ const f = model.routes.find((r) => r.op === "avatar" && r.map?.numFrames)?.map?.numFrames;+ const frames = f ? numFramesValue(f, { sourceDuration: seconds, fps }) : undefined;+ return f && frames ? frames / f.fps : seconds;+}+/*** A prompt without the trigger words of LoRAs a run leaves out: an open motion's template starts with its LoRA's* trigger ("e13c7r1c electricity effect. …", see withOssLoras), which means nothing to the model without the LoRA.@@ -672,6 +683,8 @@ export function estimateCost(model: ModelDef, params: GenParams, jobs = 1, op?:const usd = withLoras && p.withLoras !== undefined ? (at(p.withLorasByResolution) ?? p.withLoras) : at(p.byResolution) || p.usd;let per = usd;const clip = op && CLIP_LENGTH_OPS.has(op) && params.sourceDuration && params.sourceDuration > 0 ? params.sourceDuration * (op === "interpolate" ? Math.max(1, params.slowdown ?? 1) : 1) : undefined;+ // A talking avatar is as long as its voice (params.sourceDuration: the voice's header, read by the studio or the server).+ const voice = op === "avatar" && params.sourceDuration && params.sourceDuration > 0 ? avatarSeconds(model, params.sourceDuration, params.fps) : undefined;if (p.unit === "image") per = usd * n;// Per megapixel of every image made: Soul's sizes are known (about 1 or 2 MP), so is a size sent as fal's image_size// {width, height} (Fuobe Mixed Media's frames); other models are taken as 1 MP.@@ -680,12 +693,12 @@ export function estimateCost(model: ModelDef, params: GenParams, jobs = 1, op?:per = usd * (p.roundUp ? Math.ceil(mp - 1e-9) : mp) * n;}if (p.unit === "second") {- const seconds = clip ?? params.duration ?? model.defaults?.duration ?? 5;+ const seconds = clip ?? voice ?? params.duration ?? model.defaults?.duration ?? 5;const mp = p.videoMegapixel ? videoMegapixels(model, params, seconds) : undefined;const rate = p.videoMegapixel && (withLoras && p.videoMegapixel.withLoras !== undefined ? p.videoMegapixel.withLoras : p.videoMegapixel.usd);per = mp !== undefined && rate ? Math.ceil(mp - 1e-9) * rate : usd * seconds * (p.inputSeconds ? 2 : 1);}- if (p.unit === "minute") per = (usd * (params.duration ?? 60)) / 60;+ if (p.unit === "minute") per = (usd * (voice ?? params.duration ?? 60)) / 60;// Settings that change the price (60 fps, a Pro tier, a cheaper model).for (const f of p.factors ?? []) {const v = f.param === "targetFps" ? (params.targetFps ?? model.defaults?.targetFps) : (params.extra?.[f.param] ?? model.options.controls?.find((c) => c.param === f.param)?.default);diff --git a/src/lib/catalog/soul.ts b/src/lib/catalog/soul.tsindex 2fbf041d..7918585b 100644--- a/src/lib/catalog/soul.ts+++ b/src/lib/catalog/soul.ts@@ -52,7 +52,7 @@ export interface SoulLook {overlay?: SoulOverlay;/*** A step after the picture (O11): "face-mosaic" pixelates the faces (PixeletedFace): SAM 3.1 and a mosaic on the GPU, fal's- * SAM 3.1 masks pixelated in the browser in the cloud (src/lib/catalog/open-tools.ts).+ * SAM 3.1 masks pixelated by the server in the cloud (src/lib/catalog/open-tools.ts).*/post?: SoulPost;/** A Fuobe-trained LoRA should replace the public one or the words (research §6). */@@ -250,11 +250,6 @@ export function promptWithLoras(prompt: string, triggers: string[], kept: Pick<Lreturn after ? `${after}, ${rest}` : rest;}-/**- * What happens to a Soul result after generation, read from its request (the grade preset, the overlay and Soul- * Cinema's 21:9 crop the browser applies; meta.grade / meta.overlay / meta.crop tell API clients). Undefined for- * other models.- *//** The step a Soul run's look asks for after its picture (the face mosaic), or none. Soul Cinema has none. */export function soulPostStep(modelId: string, presetId: string | null | undefined): SoulPost | undefined {const kind = soulKind(modelId);@@ -262,6 +257,11 @@ export function soulPostStep(modelId: string, presetId: string | null | undefinereturn soulLook(presetId ?? DEFAULT_LOOK)?.post;}+/**+ * What happens to a Soul result after generation, read from its request (the grade preset, the overlay and Soul+ * Cinema's 21:9 crop the browser applies; meta.grade / meta.overlay / meta.crop tell API clients). Undefined for+ * other models.+ */export function soulPostSteps(modelId: string,presetId: string | null | undefined,diff --git a/src/lib/catalog/types.ts b/src/lib/catalog/types.tsindex b6d38634..ae417f8a 100644--- a/src/lib/catalog/types.ts+++ b/src/lib/catalog/types.ts@@ -492,6 +492,12 @@ export interface ModelRoute {* FieldMap.defaults for a graph.*/extra?: Record<string, unknown>;+ /**+ * A ComfyUI wrapper graph that loads one LoRA itself (kijai's InfiniteTalk) takes the run's LoRA in that slot, in place of+ * its own: only on a route whose recipe brings that LoRA and the settings it needs (Fuobe Speak's FusioniX with 25 steps).+ * Other routes on the graph refuse a LoRA rather than swap out the one its settings are tuned for.+ */+ loraSlot?: true;}export type Badge = "new" | "top" | "fast" | "audio" | "4k" | "hd" | "pro" | "open" | "uncensored" | "beta";@@ -876,6 +882,11 @@ export interface GenerationRequest {frame?: { scene: string; index: number; of: number };/** Part of a multi-step job (a shot of a multi-shot film, a step of an extend): shown on its tile. */step?: { label: string; index: number; of: number };+ /**+ * Server-set: the picture of a look whose step after it (PixeletedFace's face mosaic) is the next step of the same run+ * (src/server/chains.ts createMosaicRun), so it doesn't start another.+ */+ postMade?: boolean;/** Server-set: what the user calls this result, shown instead of the prompt (Library, feeds). */title?: string;/** Server-set: the name of the batch it belongs to (an Assist plan's summary): the Library stack's title. */diff --git a/src/lib/composer.ts b/src/lib/composer.tsindex c79b3097..206ae763 100644--- a/src/lib/composer.ts+++ b/src/lib/composer.ts@@ -742,10 +742,6 @@ export function followEngineParams(params: GenParams, from: GenParams, to: GenPareturn { ...params, ...Object.fromEntries(moved.map((k) => [k, to[k]])) };}-/**- * What a step before the clip adds to its price (Fuobe DoP relights a start frame first), when the run is on the- * preset's own model: a partner model runs the effect's words alone.- *//*** A step after the run that costs on its own: Fuobe Soul's PixeletedFace look pixelates each picture's faces (SAM 3.1:* free on the GPU, fal's per-request price in the cloud), one step per picture.@@ -756,6 +752,10 @@ export function postStepCost(modelId: string | undefined, look: string | undefinreturn step?.engine === "cloud" && step.pricing?.unit === "request" ? step.pricing.usd * Math.max(1, pictures) : 0;}+/**+ * What a step before the clip adds to its price (Fuobe DoP relights a start frame first), when the run is on the+ * preset's own model: a partner model runs the effect's words alone.+ */export function prestepCost(preset: Pick<Preset, "type" | "open" | "cloud" | "prestep"> | undefined, modelId: string | undefined, engine: Engine): number {if (!preset?.prestep || !modelId || presetModel(preset, engine) !== modelId) return 0;return preset.prestep[engine].usd ?? 0;diff --git a/src/lib/studios.ts b/src/lib/studios.tsindex d092dd26..fa4c3cb5 100644--- a/src/lib/studios.ts+++ b/src/lib/studios.ts@@ -109,6 +109,7 @@ export const LIPSYNC_STUDIO: StudioConfig = {anyOf: [["image", "video"]],defaultModels: { cloud: "kling-avatar-2", open: "oss-infinitetalk" },promptOptional: true,+ voiceFacts: true,};export const UPSCALE_STUDIO: StudioConfig = {diff --git a/src/server/chains.ts b/src/server/chains.tsindex f15de864..d0fb76f8 100644--- a/src/server/chains.ts+++ b/src/server/chains.ts@@ -414,38 +414,62 @@ export function createRelitClip(/*** Fuobe Soul's PixeletedFace look (O11): each picture, then its faces pixelated on the engine it was made on: one SAM 3.1 +- * mosaic graph on the GPU; in the cloud fal's SAM 3.1 finds the faces and the browser pixelates under its masks. One- * two-step pipeline per picture (a later step takes one result), all in one batch.+ * mosaic graph on the GPU; in the cloud fal's SAM 3.1 finds the faces and the server (or, for a picture it can't decode, the+ * browser) pixelates under its masks. One two-step pipeline per picture (a later step takes one result), all in one batch,+ * each picture on its own seed (seed + i, as a batch of jobs gets). A run that waits for earlier steps (a Canvas node, a+ * pipeline step) waits with its picture. The mosaics come first: a caller that takes the first result (a pipeline's next+ * step, a Canvas node) gets the pixelated picture.*/-export function createMosaicRun(original: GenerationRequest, model: ModelDef): Generation[] {+export function createMosaicRun(original: GenerationRequest, model: ModelDef, opts: { batchId?: string; dependsOn?: string[] } = {}): Generation[] {const n = Math.max(1, Math.min(4, original.params?.numOutputs ?? 1));const engine = model.engine;const step = faceMosaicStep(engine);const words = original.prompt?.trim() || "Pixelated face";- const batchId = nanoid(10);- const items: Generation[] = [];+ const seed = original.params?.seed;+ const deps = opts.dependsOn ?? [];+ const existing: Record<string, string> = Object.fromEntries(deps.map((id, i) => [`in${i}`, id]));+ const own = original.step;+ const batchId = opts.batchId ?? nanoid(10);+ const mosaics: Generation[] = [];+ const pictures: Generation[] = [];+ const made: Generation[] = [];try {for (let i = 0; i < n; i++) {const of = n > 1 ? ` ${i + 1} of ${n}` : "";- const { items: made } = createPipeline(+ const params = { ...original.params, numOutputs: 1, ...(seed !== undefined && seed >= 0 && { seed: seed + i }) };+ const { items, byKey } = createPipeline([- { key: "picture", request: { ...original, engine, params: { ...original.params, numOutputs: 1 }, step: { label: `Before the face mosaic${of}`, index: 0, of: 2 } } },+ {+ key: "picture",+ request: { ...original, engine, postMade: true, params, step: { label: own ? `${own.label} · before the face mosaic${of}` : `Before the face mosaic${of}`, index: 0, of: 2 } },+ ...(deps.length > 0 && { after: Object.keys(existing) }),+ },{key: "mosaic",- request: { feature: original.feature, modelId: step.modelId, op: step.op, prompt: step.prompt, title: words, step: { label: `Face mosaic${of}`, index: 1, of: 2 } },+ request: {+ feature: original.feature,+ modelId: step.modelId,+ op: step.op,+ prompt: step.prompt,+ title: words,+ ...(original.batchTitle && { batchTitle: original.batchTitle }),+ step: { label: own ? `${own.label}${of}` : `Face mosaic${of}`, index: 1, of: 2 },+ },after: "picture",chain: [{ slot: "images", position: "first" }],},],- { batchId },+ { batchId, ...(deps.length > 0 && { existing }) },);- items.push(...made);+ made.push(...items);+ mosaics.push(byKey.mosaic);+ pictures.push(byKey.picture);}} catch (e) {- for (const g of items) void cancelGeneration(g.id);+ for (const g of made) void cancelGeneration(g.id);throw e;}- return items;+ return [...mosaics, ...pictures];}/** The model a storyboard film is animated with. */diff --git a/src/server/generations.ts b/src/server/generations.tsindex c9fbca44..846cda4c 100644--- a/src/server/generations.ts+++ b/src/server/generations.ts@@ -12,15 +12,17 @@ import { cueText, type Cue } from "@/lib/cues";import { HELPER_FEATURES, HELPER_SUFFIX, isReviewStatus, type AssetUse, type ReviewFilter } from "@/lib/library";import { upscaleTier } from "@/lib/av/upscale";import { chainedWaitMessage, keyframeChain } from "@/lib/catalog/keyframes";-import { estimateCost, inferOperation, planGeneration, presetRoute, routeLoras, routesFor, withoutTriggers } from "@/lib/catalog/plan";+import { avatarSeconds, estimateCost, inferOperation, planGeneration, presetRoute, routeLoras, routesFor, withoutTriggers } from "@/lib/catalog/plan";import { framedLength, keepMatte } from "@/lib/catalog/payload";import { fitLoras, loraName, lorasFit } from "@/lib/catalog/loras";import { dualEngine, onEngine, pickEngine } from "@/lib/catalog/engines";import { promptWithLoras, soulKind, soulLook, soulPostStep, soulPostSteps } from "@/lib/catalog/soul";import { isDop } from "@/lib/catalog/dop";+import { postStepCost } from "@/lib/composer";import { MIXED_ORIGINAL, originalFrameSize } from "@/lib/catalog/mixed-media";import { imageSize } from "@/lib/image-size";-import { finishSteps } from "@/lib/soul-post";+import { finishSteps, mosaicPixels, unionMasks } from "@/lib/soul-post";+import { ANGLES_ORIGINAL, MOSAIC_SCALE } from "@/lib/catalog/open-tools";import {CHAIN_LIST_SLACK,LAST_FRAME_CHAIN,@@ -54,7 +56,7 @@ import { offeredLoras, offeredRoutes, requireOffered } from "./model-access";import { llmBackends, llmMissing, llmUsesClaude, probeOllama } from "./providers/llm";import type { PollContext, PollResult, RemoteOutput } from "./providers/types";import { mediaFacts } from "./media-facts";-import { convertMask } from "./png";+import { convertMask, decodePng, encodePng } from "./png";import { engineMode, getSetting } from "./settings";import { fetchRemoteToFile } from "./remote-fetch";import { adoptFile, contentTypeFor, deleteAsset, localHead, readRef, saveFile, scratchDir } from "./storage";@@ -499,12 +501,14 @@ export function offeredFor(m: ModelDef, asked: Engine | undefined): ModelDef {}/**- * Fuobe Mixed Media's single picture in the cloud (DoP's Mixed Media stills, an API caller's edit) drawn at about 1- * megapixel in its picture's shape, as it's priced: without a size, fal keeps the upload's own (a 12-megapixel photo- * costs 12 times as much). The studio sends each frame's size itself; a picture that isn't a file in Fuobe keeps fal's.+ * Fuobe Mixed Media's single picture in the cloud (DoP's Mixed Media stills, an API caller's edit), and Fuobe Angles' other+ * camera, drawn at about 1 megapixel in its picture's shape, as it's priced (and as the GPU graphs scale it): without a+ * size, fal keeps the upload's own (a 12-megapixel photo costs 12 times as much). The studio sends each Mixed Media frame's+ * size itself; a picture that isn't a file in Fuobe keeps fal's.*/+const SIZED_EDITS = new Set([MIXED_ORIGINAL, ANGLES_ORIGINAL]);function sizedMixedFrame(plan: ReturnType<typeof planGeneration>, req: GenerationRequest): ReturnType<typeof planGeneration> {- if (plan.model.id !== MIXED_ORIGINAL || plan.model.engine !== "cloud" || plan.op !== "edit" || plan.params.extra?.image_size) return plan;+ if (!SIZED_EDITS.has(plan.model.id) || plan.model.engine !== "cloud" || plan.op !== "edit" || plan.params.extra?.image_size) return plan;const first = req.inputs?.images?.[0];const head = first ? localHead(first) : null;const size = head ? imageSize(head) : null;@@ -583,6 +587,14 @@ function prepare(original: GenerationRequest) {const span = f.min !== undefined && f.max !== undefined ? ` makes ${half(f.min / fps)}–${half(f.max / fps)} s clips,` : "";notes.push(`${plan.model.name} on ${provider(route.provider).label}${span} so this one is about ${half(made)} s, not ${seconds} s`);}+ // A talking avatar is as long as its voice, up to what a frame-count route makes a call (fal's InfiniteTalk about 29 s, Wan+ // 2.2 S2V 7.5 s): a longer voice is cut there, and said.+ const voice = !demo && plan.op === "avatar" && route.map?.numFrames ? plan.params.sourceDuration : undefined;+ if (voice && voice > 0) {+ const reach = avatarSeconds({ routes: [route] }, voice, plan.params.fps);+ const half = (x: number) => Math.round(x * 2) / 2;+ if (reach < voice - 0.25) notes.push(`${plan.model.name} on ${provider(route.provider).label} makes up to ${half(reach)} s a call, so this one stops ${half(reach)} s into the ${half(voice)} s voice`);+ }// A route that can't batch (Replicate's Nano Banana Pro beside fal's num_images; a ComfyUI graph, which makes// one picture a run: Fuobe Soul on the open engine) runs one job per output.if (!demo && !route.map?.numOutputs && plan.perJobOutputs > 1) {@@ -613,6 +625,8 @@ export function previewGeneration(asked: GenerationRequest) {...fitted,dropped: [...switchedOff, ...unreachable.map((l) => ({ file: l.file, reason: "it downloads from civitai, which needs your civitai key (Settings → LoRAs)" })), ...fitted.dropped],};+ // PixeletedFace pixelates each picture's faces afterwards (createMosaicRun): fal's SAM 3.1 per picture in the cloud.+ const post = demo || moved.request.postMade ? 0 : postStepCost(plan.model.id, moved.request.presetId, plan.model.engine, plan.jobs * plan.perJobOutputs, getModel);return {model: plan.model,op: plan.op,@@ -620,7 +634,7 @@ export function previewGeneration(asked: GenerationRequest) {outputs: plan.jobs * plan.perJobOutputs,demo,providerId,- costUsd: cost === null ? null : cost * plan.jobs,+ costUsd: cost === null ? null : post ? Math.round((cost * plan.jobs + post) * 1000) / 1000 : cost * plan.jobs,// The engine it runs on (a Fuobe Original picks one per request).engine: plan.model.engine,// What the route runs (the evaluation harness records it): the provider endpoint, the final prompt and the LoRAs it loads.@@ -681,10 +695,11 @@ export function createGenerations(asked: GenerationRequest, opts: CreateOptions// Fuobe DoP's relight effects: the start frame is relit first, then animated.const relight = !opts.dependsOn && shotModel ? relightStep(original, shotModel) : undefined;if (relight) return createRelitClip(original, relight);- // Fuobe Soul's PixeletedFace look: the picture, then its faces pixelated (SAM 3.1 + a mosaic). A step of a pipeline- // (Soul's own picture inside this one) runs as it is.- if (!opts.dependsOn && !original.step && shotModel && soulPostStep(shotModel.id, original.presetId) === "face-mosaic") {- return createMosaicRun(original, shotModel);+ // Fuobe Soul's PixeletedFace look: the picture, then its faces pixelated (SAM 3.1 + a mosaic), also as a pipeline step or a+ // Canvas node (it waits for what they wait for). The picture made inside that run (postMade) runs as it is.+ if (!original.postMade && shotModel && soulPostStep(shotModel.id, original.presetId) === "face-mosaic") {+ const waitsFor = opts.dependsOn === undefined ? undefined : Array.isArray(opts.dependsOn) ? opts.dependsOn : [opts.dependsOn];+ return createMosaicRun(original, shotModel, { batchId: opts.batchId, dependsOn: waitsFor });}const deps = opts.dependsOn === undefined ? [] : Array.isArray(opts.dependsOn) ? opts.dependsOn : [opts.dependsOn];const waits = deps.length > 0;@@ -1171,6 +1186,10 @@ async function submit(};// What the caller said about the clip's length wins; the header fills the rest.Object.assign(input, { ...source, ...(plan.params.sourceDuration !== undefined && { sourceDuration: plan.params.sourceDuration }) });+ // A talking avatar renders as long as its voice: priced for it once its header is read (an API call that didn't say).+ if (plan.op === "avatar" && plan.params.sourceDuration === undefined && input.sourceDuration && providerId !== "mock" && plan.model.engine !== "open") {+ update(id, { cost_usd: estimateCost(plan.model, { ...plan.params, sourceDuration: input.sourceDuration }, 1, plan.op, plan.loras.length > 0 && !!route.loraEndpoint) });+ }// An upscale that wouldn't enlarge the clip (a 1080p clip at a default 1080p; a 4K clip would even shrink):// a tier the model only defaulted to moves up to the next one it offers, one the caller picked is refused.if (plan.op === "upscale-video" && input.sourceSize) {@@ -1406,30 +1425,29 @@ async function pollOne(r: Row): Promise<void> {const outputs: OutputFile[] = [];// Remove background: of a cut-out and its mask (BiRefNet's answer), the one asked for (params.matteOutput).const matte = r.op === "bg-remove-video" ? (JSON.parse(r.request_json) as GenerationRequest).params?.matteOutput : undefined;- for (const o of keepMatte(res.outputs as RichOutput[], matte)) {+ // The face mosaic's cloud step answers with the faces' masks: the result is the picture, pixelated under them.+ const faceMasks = r.op === "face-mosaic" && res.outputs.length > 0 && (res.outputs as RichOutput[]).every((o) => o.meta?.role === "mask" && Array.isArray(o.meta.masks));+ if (faceMasks) {try {- outputs.push(await persistOutput(o, r.id));+ outputs.push(await mosaicOutput(r, res.outputs as RichOutput[]));} catch (e) {- outputs.push({ url: o.url, kind: o.kind ?? r.kind, ...inlineText(o.text, o.meta), ...(o.draftId ? { draftId: o.draftId } : {}) });- console.warn(`[fuobe] could not save output for ${r.id}: ${(e as Error).message}`);+ update(r.id, { status: "failed", error: (e as Error).message, completed_at: Date.now(), message: null });+ return;+ }+ } else {+ for (const o of keepMatte(res.outputs as RichOutput[], matte)) {+ try {+ outputs.push(await persistOutput(o, r.id));+ } catch (e) {+ outputs.push({ url: o.url, kind: o.kind ?? r.kind, ...inlineText(o.text, o.meta), ...(o.draftId ? { draftId: o.draftId } : {}) });+ console.warn(`[fuobe] could not save output for ${r.id}: ${(e as Error).message}`);+ }}}// Fuobe Soul: what follows in the browser (the look's grade, an overlay, Soul Cinema's 21:9 crop), on each image;// API clients read it as meta.const post = soulPostSteps(r.model_id, r.preset_id, soulKind(r.model_id) ? requestAspect(r.request_json) : undefined);if (post) for (const [i, o] of outputs.entries()) if (o.kind === "image") outputs[i] = { ...o, meta: { ...o.meta, ...post } };- // The face mosaic's cloud step (fal's SAM 3.1): its outputs are the faces' masks; the browser pixelates the picture it- // looked at under them (meta.mosaic, src/lib/soul-post.ts), as it finishes Soul's looks.- if (r.op === "face-mosaic") {- const source = (JSON.parse(r.request_json) as GenerationRequest).inputs?.images?.[0];- const scale = (JSON.parse(r.request_json) as GenerationRequest).params?.extra?.mosaicScale;- for (const [i, o] of outputs.entries()) {- const masks = o.meta?.masks;- if (o.kind === "image" && source && Array.isArray(masks) && masks.length) {- outputs[i] = { ...o, meta: { ...o.meta, mosaic: { source, masks, ...(typeof scale === "number" && { scale }) } } };- }- }- }// Fuobe DoP's colour-grade effects: the grade the browser applies to the clip (the result's "Apply the grade" step).const grade = isDop(r.model_id) && r.preset_id ? getPreset(r.preset_id)?.grade : undefined;if (grade) for (const [i, o] of outputs.entries()) if (o.kind === "video") outputs[i] = { ...o, meta: { ...o.meta, grade } };@@ -1442,6 +1460,50 @@ async function pollOne(r: Row): Promise<void> {});}+/**+ * The face mosaic's cloud step (fal's SAM 3.1 answered with the faces' masks): the picture it looked at, pixelated under+ * every mask, made here when the picture and the masks are PNGs (fal's Soul pictures are), so the Library, share links,+ * Canvas and API clients get the finished picture. A picture the server can't decode is kept as it is with the masks+ * (meta.mosaic) for the browser to pixelate (src/components/studio/soul-finish.ts). No face found: the picture as it is, as+ * the GPU graph returns it. The masks are kept as files of the generation (meta.masks).+ */+async function mosaicOutput(r: Row, given: RichOutput[]): Promise<OutputFile> {+ const req = JSON.parse(r.request_json) as GenerationRequest;+ const source = req.inputs?.images?.[0];+ if (!source) throw new Error("The face mosaic has no picture to pixelate");+ const asked = req.params?.extra?.mosaicScale;+ const scale = typeof asked === "number" && asked > 0 && asked < 1 ? asked : MOSAIC_SCALE;+ const links = given.flatMap((o) => (o.meta?.masks as unknown[]).filter((u): u is string => typeof u === "string" && !!u));+ const masks: string[] = [];+ for (const [i, url] of [...new Set(links)].entries()) masks.push(String(await keepLink(url, `mask-${i}`, r.id)));+ const picture = await readRef(source);+ let data = picture.data;+ let contentType = picture.contentType;+ let done = !masks.length;+ if (masks.length) {+ try {+ const img = decodePng(picture.data);+ const layers = await Promise.all(masks.map(async (m) => decodePng((await readRef(m)).data)));+ if (layers.some((l) => l.width !== img.width || l.height !== img.height)) throw new Error("The masks aren't the picture's size");+ const view = (b: Buffer) => new Uint8ClampedArray(b.buffer, b.byteOffset, b.byteLength);+ mosaicPixels(view(img.data), unionMasks(layers.map((l) => view(l.data))), img.width, img.height, scale);+ data = encodePng(img);+ contentType = "image/png";+ done = true;+ } catch (e) {+ console.warn(`[fuobe] face mosaic ${r.id} is left to the browser: ${(e as Error).message}`);+ }+ }+ const asset = saveFile({ data, contentType, source: "generation", generationId: r.id });+ return {+ url: asset.url,+ kind: "image",+ contentType: asset.contentType,+ assetId: asset.id,+ meta: { masks, faces: masks.length, ...(!done && { mosaic: { source: asset.url, masks, scale } }) },+ };+}+/** Outputs may carry text (transcripts, translations, scripts) and structured extras (layer boxes, cues, stems). */type RichOutput = RemoteOutput & { text?: string; meta?: Record<string, unknown> };@@ -1475,21 +1537,12 @@ export async function persistArtifacts(meta: Record<string, unknown> | undefinedout = { ...out, [key]: kept };}for (const key of LINKS) if (typeof meta[key] === "string" && meta[key] !== main) out = { ...out, [key]: await keepLink(meta[key], key, generationId) };- for (const key of LINK_LISTS) {- const list = meta[key];- if (!Array.isArray(list)) continue;- const kept: unknown[] = [];- for (const [i, v] of list.entries()) kept.push(v === main ? v : await keepLink(v, `${key}-${i}`, generationId));- out = { ...out, [key]: kept };- }return out;}/** Maps of extra files by name, and single extra files, that a result links to (see persistArtifacts). */const LINK_MAPS = ["artifacts", "formats"] as const;const LINKS = ["preview"] as const;-/** Lists of extra files: SAM 3.1's masks of the faces (the face mosaic's cloud step), kept here so the browser can read them. */-const LINK_LISTS = ["masks"] as const;/** A provider's link stored as a file of the generation (its local URL), or the link as it was when it can't be fetched. */async function keepLink(v: unknown, label: string, generationId: string): Promise<unknown> {@@ -1520,10 +1573,6 @@ function relinkMain(meta: Record<string, unknown> | undefined, from: string, to:out = { ...out, [key]: Object.fromEntries(Object.entries(links as Record<string, unknown>).map(([k, v]) => [k, v === from ? to : v])) };}for (const key of LINKS) if (meta[key] === from) out = { ...out, [key]: to };- for (const key of LINK_LISTS) {- const list = meta[key];- if (Array.isArray(list) && list.includes(from)) out = { ...out, [key]: list.map((v) => (v === from ? to : v)) };- }return out;}diff --git a/src/server/providers/comfyui.ts b/src/server/providers/comfyui.tsindex 32cbf1f7..e6020efe 100644--- a/src/server/providers/comfyui.ts+++ b/src/server/providers/comfyui.ts@@ -680,6 +680,11 @@ export interface PrepareContext {media?: (name: string) => MediaInfo | undefined;/** The ComfyUI server's RAM in bytes, for graphs that hold a whole clip in memory. */serverRam?: () => Promise<number | undefined>;+ /**+ * The route puts the run's one LoRA in the graph's own LoRA slot (ModelRoute.loraSlot: Fuobe Speak's FusioniX on kijai's+ * InfiniteTalk graph, with the settings it goes with). Without it a graph with no model loader refuses a LoRA.+ */+ loraSlot?: boolean;}export interface PreparedPrompt {@@ -925,14 +930,19 @@ export async function prepareWorkflow(endpointTemplate: string, input: GenInput,Object.assign(values, { width: clip.width, height: clip.height, fps: Math.round(clip.fps * 1000) / 1000 });}if (b.frames && span) values.frames = computeFrames(span, fps, Number(d.frameStep ?? 4), manifest.limits?.maxFrames);- // Lip re-sync runs as long as the new voice; a voice past the frame cap is refused, not cut.- const voiceLength = ctx.op === "lipsync" && b.frames && !span ? ctx.media?.(String(values.audio ?? ""))?.duration : undefined;+ // Lip re-sync and a talking avatar run as long as the voice (its header, or the length the run was given); a voice past+ // the frame cap is refused, not cut.+ const voiceLength =+ (ctx.op === "lipsync" || ctx.op === "avatar") && b.frames && !span+ ? (ctx.op === "avatar" && input.sourceDuration && input.sourceDuration > 0 ? input.sourceDuration : ctx.media?.(String(values.audio ?? ""))?.duration)+ : undefined;if (voiceLength) {const step = Number(d.frameStep ?? 4);const frames = Math.ceil((voiceLength * fps) / step) * step + 1;const cap = Number(manifest.limits?.maxFrames ?? 0);if (cap && frames > cap) {- throw new ProviderError(`Lip re-sync on the open engine takes up to ${seconds(cap / fps)} s of speech per job (this voice is ${seconds(voiceLength)} s) — split it into shorter parts`);+ const what = ctx.op === "avatar" ? "A talking avatar" : "Lip re-sync";+ throw new ProviderError(`${what} on the open engine takes up to ${seconds(cap / fps)} s of speech per job (this voice is ${seconds(voiceLength)} s) — split it into shorter parts`);}values.frames = frames;}@@ -1135,9 +1145,11 @@ export async function prepareWorkflow(endpointTemplate: string, input: GenInput,}if (b.sideBySide && input.sideBySide !== undefined) values.sideBySide = input.sideBySide;// A wrapper graph that loads its LoRA itself (kijai's InfiniteTalk: WanVideoLoraSelect, no core model loader to attach- // one after) takes the run's LoRA there: Fuobe Speak's FusioniX in place of the graph's lightx2v. One at most.+ // one after) takes the run's LoRA there on a route made for it: Fuobe Speak's FusioniX in place of the graph's lightx2v,+ // with the steps and guidance it needs. One at most. Other routes on the graph (InfiniteTalk Long, tuned for lightx2v)+ // refuse a LoRA below.let loras = input.loras ?? [];- if (loras.length && b.lora && !canTakeLoras(workflow)) {+ if (loras.length && b.lora && ctx.loraSlot && !canTakeLoras(workflow)) {if (loras.length > 1) throw new ProviderError(`${manifest.title} takes one LoRA (it loads it itself): ${loras.map((l) => l.file).join(", ")}`);values.lora = loras[0].file;values.loraStrength = loras[0].strength ?? 1;@@ -1430,6 +1442,7 @@ export const comfyProvider: ProviderAdapter = {const { manifest, workflow: wf, meta } = await prepareWorkflow(route.endpoint, asked, {generationId,op: route.op,+ loraSlot: route.loraSlot === true,upload: (data, contentType, name) => uploadTo(worker, data, contentType, name),media: mediaInfoFor,serverRam: async () => (await comfyJson<{ system?: { ram_total?: number } }>("/system_stats", worker).catch(() => undefined))?.system?.ram_total,diff --git a/tests/av-tools.test.ts b/tests/av-tools.test.tsindex 38a492c0..e7b072b7 100644--- a/tests/av-tools.test.ts+++ b/tests/av-tools.test.ts@@ -158,7 +158,7 @@ describe("extract frame on both engines", () => {describe("apps on the new models", () => {// Every app this package routes runs with only its inputs on both engines: no note needed, the pinned model, its settings.- const ids = ["app-virtual-try-on", "app-angles", "app-product-shot", "app-image-to-3d", "app-hook-frame"];+ const ids = ["app-virtual-try-on", "app-angles", "app-fuobe-angles", "app-product-shot", "app-image-to-3d", "app-hook-frame"];const plan = (id: string, engine: "cloud" | "open", presetOptions?: Record<string, string>) => {const preset = getPreset(id)!;const route = engine === "cloud" ? preset.cloud! : preset.open!;@@ -181,12 +181,23 @@ describe("apps on the new models", () => {expect(plan("app-image-to-3d", "open").model.id).toBe("oss-trellis2");});- it("Angles: the choices set the camera fields on the cloud and the LoRA's words on the open engine (Fuobe Angles, O11)", () => {- const choice = { rotate: "45-right", height: "from-above", distance: "close-up" };+ it("Angles: the choices set the camera sliders on the cloud and the LoRA's words on the open engine", () => {+ const choice = { angle: "back-left", height: "high-angle", distance: "close-up" };const cloud = plan("app-angles", "cloud", choice);+ expect(cloud.model.id).toBe("qwen-multiple-angles");+ expect(cloud.params.extra).toMatchObject({ horizontal_angle: 225, vertical_angle: 60, zoom: 10 });+ expect(cloud.prompt.length).toBeGreaterThan(0);+ const open = plan("app-angles", "open", choice);+ expect(open.prompt).toMatch(/^<sks> back-left quarter view high-angle shot close-up/);+ expect(open.loras[0]?.file).toMatch(/multiple-angles/);+ });++ it("Fuobe Angles: the choices set the camera fields on the cloud and the LoRA's words on the open engine (O11)", () => {+ const choice = { rotate: "45-right", height: "from-above", distance: "close-up" };+ const cloud = plan("app-fuobe-angles", "cloud", choice);expect(cloud.model.id).toBe("fuobe-angles");expect(cloud.params.extra).toMatchObject({ rotate_right_left: -45, vertical_angle: -1, move_forward: 10 });- const open = plan("app-angles", "open", choice);+ const open = plan("app-fuobe-angles", "open", choice);expect(open.prompt).toMatch(/^将镜头向右旋转45度 Rotate the camera 45 degrees to the right\. .*Turn the camera to a close-up\. .*bird's-eye view\.$/);expect(open.loras[0]?.file).toMatch(/multiple-angles/);});diff --git a/tests/open-tools.test.ts b/tests/open-tools.test.tsindex 57be285c..99563015 100644--- a/tests/open-tools.test.ts+++ b/tests/open-tools.test.ts@@ -15,7 +15,12 @@ process.env.FUOBE_DATA_DIR = dir;process.env.COMFYUI_URL = "http://127.0.0.1:9"; // nothing listens here: open runs fall back to the democonst { setSetting } = await import("@/server/settings");-const { createGenerations, getGeneration, previewGeneration } = await import("@/server/generations");+const { createGenerations, ensureRunner, getGeneration, previewGeneration } = await import("@/server/generations");+const { createPipeline } = await import("@/server/chains");+const { db } = await import("@/server/db");+const { saveFile, readRef } = await import("@/server/storage");+const { decodePng, encodePng } = await import("@/server/png");+const { mockProvider } = await import("@/server/providers/mock");const { falProvider } = await import("@/server/providers/fal");const { prepareWorkflow, getWorkflow } = await import("@/server/providers/comfyui");const { getModel, getPreset } = await import("@/lib/catalog");@@ -36,11 +41,30 @@ const plan = (r: Parameters<typeof planGeneration>[0], engine: "open" | "cloud")planGeneration(r, (id) => (getModel(id)?.engines ? view(id, engine) : getModel(id)), getPreset);const research = JSON.parse(fs.readFileSync(path.join(__dirname, "../docs/research/fuobe-originals-recipes-5.json"), "utf8"));-async function prepare(id: string, input: GenInput, op: Operation): Promise<ComfyWorkflow> {- const { workflow } = await prepareWorkflow(id, { seed: 7, ...input }, { generationId: "g", op, upload: async (_d, _t, name) => `up_${name}`, media: () => undefined, serverRam: async () => undefined });+async function prepare(id: string, input: GenInput, op: Operation, ctx: { loraSlot?: boolean; media?: (name: string) => { duration?: number } | undefined } = {}): Promise<ComfyWorkflow> {+ const { workflow } = await prepareWorkflow(id, { seed: 7, ...input }, { generationId: "g", op, upload: async (_d, _t, name) => `up_${name}`, media: (ctx.media ?? (() => undefined)) as never, serverRam: async () => undefined, loraSlot: ctx.loraSlot });return workflow;}+const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));+async function settled(id: string, ms = 20_000) {+ const end = Date.now() + ms;+ for (;;) {+ const g = getGeneration(id)!;+ if (["succeeded", "failed", "canceled"].includes(g.status)) return g;+ if (Date.now() > end) throw new Error(`${id} is still ${g.status}`);+ await sleep(50);+ }+}++/** A `w` × `h` PNG: `paint(x, y)` gives each pixel's RGB. */+function png(w: number, h: number, paint: (x: number, y: number) => [number, number, number]): Buffer {+ const data = Buffer.alloc(w * h * 4);+ for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) data.set([...paint(x, y), 255], (y * w + x) * 4);+ return encodePng({ width: w, height: h, data });+}+const dataUri = (b: Buffer) => `data:image/png;base64,${b.toString("base64")}`;+/** Submit through the fal adapter and return the endpoint URL and the JSON body it posted. */async function submit(model: ModelDef, route: ModelRoute, given: GenInput): Promise<{ url: string; body: Record<string, unknown> }> {const real = globalThis.fetch;@@ -88,8 +112,28 @@ describe("Fuobe Angles", () => {expect(cloud.routes[0].map?.prompt).toBe(false);});- it("the Angles app turns its picks into fal's fields in the cloud and the LoRA's words on your GPU", async () => {- const req = { feature: "app:app-angles", modelId: "fuobe-angles", presetId: "app-angles", prompt: "keep the logo", inputs: { images: ["/a.png"] }, presetOptions: { rotate: "90-right", height: "from-above", distance: "close-up", lens: "wide" } };+ it("the Angles app keeps its 2511 recipe until the angles eval suite promotes Fuobe Angles: results made before O11 run again", () => {+ const angles = getPreset("app-angles")!;+ expect([angles.cloud?.modelId, angles.open?.modelId]).toEqual(["qwen-multiple-angles", "oss-qwen-edit"]);+ expect(angles.open?.loras).toEqual([tools.ANGLES_2511_LORA]);+ // A stored Angles request (Retry, Reuse, an API client's script) plans as it did, on both engines.+ const old = { feature: "app:app-angles", presetId: "app-angles", op: "edit" as const, inputs: { images: ["/api/files/a.png"] }, presetOptions: { angle: "back-left", height: "high-angle", distance: "close-up" } };+ expect(plan({ ...old, modelId: "qwen-multiple-angles" }, "cloud").params.extra).toMatchObject({ horizontal_angle: 225, vertical_angle: 60, zoom: 10 });+ expect(previewGeneration({ ...old, modelId: "qwen-multiple-angles" }).model.id).toBe("qwen-multiple-angles");+ expect(previewGeneration({ ...old, modelId: "oss-qwen-edit" }).model.id).toBe("oss-qwen-edit");+ expect(plan({ ...old, modelId: "oss-qwen-edit" }, "open").prompt).toMatch(/^<sks> back-left quarter view high-angle shot close-up/);+ expect(createGenerations({ ...old, modelId: "qwen-multiple-angles" })).toHaveLength(1);+ // Fuobe Angles is its own app next to it, marked as not yet measured; the suite that measures it is in place.+ const fuobe = getPreset("app-fuobe-angles")!;+ expect([fuobe.cloud?.modelId, fuobe.open?.modelId, fuobe.category]).toEqual(["fuobe-angles", "fuobe-angles", angles.category]);+ expect(fuobe.badges).toContain("beta");+ const suite = JSON.parse(fs.readFileSync(path.join(__dirname, "../scripts/eval/cases/angles.json"), "utf8"));+ expect(suite).toMatchObject({ original: "fuobe-angles", defaults: { candidate: "recipe" } });+ expect(Object.keys(suite.variants)).toEqual(["recipe", "today-open", "today-cloud"]);+ });++ it("the Fuobe Angles app turns its picks into fal's fields in the cloud and the LoRA's words on your GPU", async () => {+ const req = { feature: "app:app-fuobe-angles", modelId: "fuobe-angles", presetId: "app-fuobe-angles", prompt: "keep the logo", inputs: { images: ["/a.png"] }, presetOptions: { rotate: "90-right", height: "from-above", distance: "close-up", lens: "wide" } };const open = plan(req, "open");expect(open.prompt).toBe("将镜头向右旋转90度 Rotate the camera 90 degrees to the right. 将镜头转为特写镜头 Turn the camera to a close-up. 将相机转向鸟瞰视角 Turn the camera to a bird's-eye view. 将镜头转为广角镜头 Turn the camera to a wide-angle lens. keep the logo",@@ -129,6 +173,33 @@ describe("Fuobe Angles", () => {expect(wf["433:436"].inputs.value).toBe(6);expect(wf["78"].inputs.image).toBe("a.png");});++ it("asks fal for about 1 megapixel in the photo's shape, as it's priced and as the GPU graph scales it", async () => {+ // Without a size fal draws (and bills) the photo's own: a 12-megapixel phone photo would cost 12 times the price shown.+ const photo = saveFile({ data: png(400, 300, () => [120, 80, 40]), contentType: "image/png", source: "upload" });+ const submit = mockProvider.submit;+ const seen: GenInput[] = [];+ mockProvider.submit = async (ctx) => {+ if (ctx.model.id === "fuobe-angles") seen.push(ctx.input);+ return submit(ctx);+ };+ try {+ createGenerations({ feature: "app:app-fuobe-angles", presetId: "app-fuobe-angles", modelId: "fuobe-angles", engine: "cloud", inputs: { images: [photo.url] } });+ for (let i = 0; i < 200 && !seen.length; i++) await sleep(25);+ expect(seen[0]?.extra).toMatchObject({ rotate_right_left: 45, image_size: { width: 1184, height: 880 } });+ } finally {+ mockProvider.submit = submit;+ }+ // Priced for the size it asks for; a size the caller sends is kept.+ setSetting("falKey", "fal_test_key_123456");+ try {+ const ask = (extra: Record<string, unknown>) => previewGeneration({ feature: "image", modelId: "fuobe-angles", engine: "cloud", op: "edit", inputs: { images: [photo.url] }, params: { extra } }).costUsd;+ expect(ask({ rotate_right_left: 45 })).toBeCloseTo(0.035, 3);+ expect(ask({ rotate_right_left: 45, image_size: { width: 2048, height: 2048 } })).toBeCloseTo(0.14, 3);+ } finally {+ setSetting("falKey", "");+ }+ });});describe("Fuobe Speak", () => {@@ -153,6 +224,90 @@ describe("Fuobe Speak", () => {expect(estimateCost(view("fuobe-speak", "open"), { duration: 10 })).toBe(0);});+ it("prices a talking avatar for its voice, as fal bills the frames it renders", () => {+ const speak = view("fuobe-speak", "cloud");+ // The Lipsync studio sends no duration: without the voice's length it's the 5 s guess; with it, the voice's seconds.+ expect(estimateCost(speak, {}, 1, "avatar")).toBeCloseTo(1, 5);+ expect(estimateCost(speak, { sourceDuration: 25 }, 1, "avatar")).toBeCloseTo(5, 5);+ // Past fal's 721 frames (28.84 s) it renders, and bills, 721.+ expect(estimateCost(speak, { sourceDuration: 40 }, 1, "avatar")).toBeCloseTo(5.768, 3);+ // Wan 2.2 S2V: frames ÷ 16 video seconds, a multiple of 4 frames, 120 at most (7.5 s).+ const motion = view("fuobe-speak-motion", "cloud");+ expect(estimateCost(motion, { sourceDuration: 7.5, resolution: "720p" }, 1, "avatar")).toBeCloseTo(1.5, 5);+ expect(estimateCost(motion, { sourceDuration: 30, resolution: "480p" }, 1, "avatar")).toBeCloseTo(0.75, 5);+ // Partner avatars bill the voice's seconds too.+ expect(estimateCost(getModel("kling-avatar-2")!, { sourceDuration: 12 }, 1, "avatar")).toBeCloseTo(1.38, 5);+ // Lip re-sync of a clip isn't priced by the voice.+ expect(estimateCost(speak, { sourceDuration: 25 }, 1, "lipsync")).toBeCloseTo(1, 5);+ });++ it("says when fal stops a voice short, and prices the run for the voice once the server reads its header", async () => {+ setSetting("falKey", "fal_test_key_123456");+ try {+ const p = previewGeneration({ feature: "lipsync", modelId: "fuobe-speak", engine: "cloud", inputs: { images: ["/api/files/p.png"], audio: "/api/files/v.wav" }, params: { sourceDuration: 40 } });+ expect(p.costUsd).toBeCloseTo(5.768, 3);+ expect(p.notes?.join(" ")).toMatch(/makes up to 29 s a call, so this one stops 29 s into the 40 s voice/);+ expect(previewGeneration({ feature: "lipsync", modelId: "fuobe-speak", engine: "cloud", inputs: { images: ["/api/files/p.png"], audio: "/api/files/v.wav" }, params: { sourceDuration: 12 } }).notes ?? []).not.toContainEqual(expect.stringMatching(/stops/));+ } finally {+ setSetting("falKey", "");+ }+ // An API call that didn't say how long the voice is: priced for the voice when submit reads its header.+ const wav = (seconds: number) => {+ const rate = 8000;+ const data = Buffer.alloc(rate * seconds * 2);+ const head = Buffer.alloc(44);+ head.write("RIFF", 0);+ head.writeUInt32LE(36 + data.length, 4);+ head.write("WAVEfmt ", 8);+ head.writeUInt32LE(16, 16);+ head.writeUInt16LE(1, 20);+ head.writeUInt16LE(1, 22);+ head.writeUInt32LE(rate, 24);+ head.writeUInt32LE(rate * 2, 28);+ head.writeUInt16LE(2, 32);+ head.writeUInt16LE(16, 34);+ head.write("data", 36);+ head.writeUInt32LE(data.length, 40);+ return Buffer.concat([head, data]);+ };+ const voice = saveFile({ data: wav(12), contentType: "audio/wav", source: "upload" });+ const face = saveFile({ data: png(64, 64, () => [200, 160, 140]), contentType: "image/png", source: "upload" });+ setSetting("falKey", "fal_test_key_123456");+ const real = globalThis.fetch;+ const bodies: Record<string, unknown>[] = [];+ globalThis.fetch = (async (url: string, init?: RequestInit) => {+ if (String(url).includes("fal-ai/infinitalk")) bodies.push(JSON.parse(String(init?.body ?? "{}")));+ return new Response(JSON.stringify({ request_id: "r1", status_url: "https://queue.fal.test/s", response_url: "https://queue.fal.test/r", cancel_url: "https://queue.fal.test/c", file_url: "https://v3.fal.media/files/x", upload_url: "https://upload.fal.test/u" }), { status: 200 });+ }) as typeof fetch;+ const { falProvider: fal } = await import("@/server/providers/fal");+ const upload = fal.prepareFile;+ fal.prepareFile = async (_d, _t, name) => `https://v3.fal.media/files/${name}`;+ try {+ const [g] = createGenerations({ feature: "lipsync", modelId: "fuobe-speak", engine: "cloud", inputs: { images: [face.url], audio: voice.url } });+ expect(g.costUsd).toBeCloseTo(1, 5);+ for (let i = 0; i < 200 && !bodies.length; i++) await sleep(25);+ expect(bodies[0]).toMatchObject({ num_frames: 300 });+ for (let i = 0; i < 100 && getGeneration(g.id)!.costUsd !== 2.4; i++) await sleep(25);+ expect(getGeneration(g.id)!.costUsd).toBeCloseTo(2.4, 5);+ // Nothing is listening at fal's test queue: stop the job here so the runner doesn't keep polling it.+ db().prepare("UPDATE generations SET status = 'canceled' WHERE id = ?").run(g.id);+ } finally {+ globalThis.fetch = real;+ fal.prepareFile = upload;+ setSetting("falKey", "");+ }+ });++ it("on your GPU renders as long as the voice (not the graph's 20 s), and refuses one past its 40 s cap", async () => {+ const m = view("fuobe-speak", "open");+ const run = (input: Partial<GenInput>, media?: (name: string) => { duration?: number } | undefined) =>+ prepare("infinitetalk-wanwrapper", { prompt: tools.SPEAK_PROMPT, images: ["face.png"], audio: "voice.wav", loras: m.options.loras, extra: { ...m.routes[0].extra }, ...input }, "avatar", { loraSlot: true, media });+ expect((await run({ sourceDuration: 30 }))["270"].inputs.value).toBe(753);+ // The voice's header when the run doesn't say.+ expect((await run({}, (name) => (name === "voice.wav" ? { duration: 8 } : undefined)))["270"].inputs.value).toBe(201);+ await expect(run({ sourceDuration: 45 })).rejects.toThrow(/A talking avatar on the open engine takes up to 40 s of speech per job \(this voice is 45 s\)/);+ });+it("sends Higgsfield's Infinite Talk settings on your GPU: FusioniX in the wrapper's LoRA slot, 15 motion frames, 25 steps, shift 10, guidance 5 / 5", async () => {const m = view("fuobe-speak", "open");expect(m.options.loras?.map((l) => l.file)).toEqual(["Wan2.1_I2V_14B_FusionX_LoRA.safetensors"]);@@ -161,8 +316,9 @@ describe("Fuobe Speak", () => {const record = research.studios.find((s: { id: string }) => s.id === "speak").original.open.defaults;expect(route.extra).toMatchObject({ motionFrame: record.motionFrame, steps: record.steps, shift: record.shift, cfg: record.cfg, audioCfg: record.audioCfg, scheduler: record.scheduler });// The provider merges the route's settings under the run's own (a run that asks for 30 steps gets 30).+ expect(route.loraSlot).toBe(true);const run = async (extra?: Record<string, unknown>) =>- prepare("infinitetalk-wanwrapper", { prompt: tools.SPEAK_PROMPT, images: ["face.png"], audio: "voice.wav", loras: m.options.loras, extra: { ...route.extra, ...extra } }, "avatar");+ prepare("infinitetalk-wanwrapper", { prompt: tools.SPEAK_PROMPT, images: ["face.png"], audio: "voice.wav", loras: m.options.loras, extra: { ...route.extra, ...extra } }, "avatar", { loraSlot: true });const wf = await run();expect(wf["138"].inputs).toMatchObject({ lora: "Wan2.1_I2V_14B_FusionX_LoRA.safetensors", strength: 1 });expect(wf["128"].inputs).toMatchObject({ steps: 25, cfg: 5, shift: 10, scheduler: "unipc" });@@ -178,7 +334,12 @@ describe("Fuobe Speak", () => {expect(plain["138"].inputs.lora).toBe("lightx2v_I2V_14B_480p_cfg_step_distill_rank64_bf16.safetensors");expect(plain["128"].inputs.steps).toBe(6);// Two LoRAs don't fit the wrapper's one slot.- await expect(prepare("infinitetalk-wanwrapper", { prompt: "talk", images: ["f.png"], audio: "v.wav", loras: [{ file: "a.safetensors" }, { file: "b.safetensors" }] }, "avatar")).rejects.toThrow(/takes one LoRA/);+ await expect(prepare("infinitetalk-wanwrapper", { prompt: "talk", images: ["f.png"], audio: "v.wav", loras: [{ file: "a.safetensors" }, { file: "b.safetensors" }] }, "avatar", { loraSlot: true })).rejects.toThrow(/takes one LoRA/);+ // InfiniteTalk Long (the same graph, tuned for its lightx2v distill LoRA: 6 steps, guidance 1) refuses a LoRA rather+ // than swap it out under those settings.+ expect(getModel("oss-infinitetalk-long")!.routes[0]).toMatchObject({ endpoint: "infinitetalk-wanwrapper" });+ expect(getModel("oss-infinitetalk-long")!.routes[0].loraSlot).toBeUndefined();+ await expect(prepare("infinitetalk-wanwrapper", { prompt: "talk", images: ["f.png"], audio: "v.wav", loras: [{ file: "my-character-wan21.safetensors", strength: 0.8 }] }, "avatar")).rejects.toThrow(/can't take LoRAs/);});it("runs without words, in the portrait's shape on your GPU", () => {@@ -248,6 +409,50 @@ describe("Soul's face mosaic", () => {expect(createGenerations({ feature: "image", modelId: "fuobe-soul", prompt: "a skater", engine: "cloud", presetId: "v1-general" })).toHaveLength(1);});+ it("gives each picture its own seed, as a batch does, and puts the mosaics first for whoever takes the first result", () => {+ for (const engine of ["open", "cloud"] as const) {+ const made = createGenerations({ feature: "image", modelId: "fuobe-soul", prompt: "a skater", engine, presetId: "v1-pixeletedface", params: { numOutputs: 3, seed: 42 } });+ const pictures = made.map((g) => getGeneration(g.id)!).filter((g) => g.modelId === "fuobe-soul");+ expect(pictures.map((g) => g.request?.params?.seed)).toEqual([42, 43, 44]);+ expect(pictures.every((g) => g.request?.postMade === true && g.request.params?.numOutputs === 1)).toBe(true);+ expect(made.slice(0, 3).map((g) => g.modelId)).toEqual(Array(3).fill(tools.FACE_MOSAIC_MODELS[engine]));+ }+ // Retrying the picture step alone doesn't start another mosaic.+ const [first] = createGenerations({ feature: "image", modelId: "fuobe-soul", prompt: "a skater", engine: "cloud", presetId: "v1-pixeletedface" });+ expect(getGeneration(first.id)!.op).toBe("face-mosaic");+ const before = createGenerations({ feature: "image", modelId: "fuobe-soul", prompt: "a skater", engine: "cloud", presetId: "v1-pixeletedface", postMade: true });+ expect(before.map((g) => g.modelId)).toEqual(["fuobe-soul"]);+ });++ it("pixelates in a pipeline step or a Canvas node too: the step waits with its picture, the next one gets the mosaic", () => {+ const dependsOn = (id: string) => {+ const v = (db().prepare("SELECT depends_on FROM generations WHERE id = ?").get(id) as { depends_on: string | null }).depends_on;+ return !v ? [] : v.startsWith("[") ? (JSON.parse(v) as string[]) : [v];+ };+ // A pipeline: a PixeletedFace picture, then an upscale of it.+ const { byKey, items } = createPipeline([+ { key: "face", request: { feature: "image", modelId: "fuobe-soul", prompt: "a skater", engine: "cloud", presetId: "v1-pixeletedface" } },+ { key: "big", request: { feature: "upscale", modelId: "topaz-image", op: "upscale-image" }, after: "face", chain: [{ slot: "images" }] },+ ]);+ expect(byKey.face.modelId).toBe("sam-3-1-face-mask");+ expect(byKey.face.op).toBe("face-mosaic");+ expect(dependsOn(byKey.big.id)).toEqual([byKey.face.id]);+ const picture = items.find((g) => g.modelId === "fuobe-soul")!;+ expect(dependsOn(byKey.face.id)).toEqual([picture.id]);+ // A Canvas node that waits for a text node: the picture waits for it, the mosaic for the picture.+ const [text] = createGenerations({ feature: "image", modelId: "nano-banana-pro", prompt: "a fox" });+ const made = createGenerations(+ { feature: "canvas", modelId: "fuobe-soul", prompt: "{text}", engine: "open", presetId: "v1-pixeletedface", chain: [{ slot: "prompt" }], step: { label: "Portrait", index: 1, of: 2 } },+ { dependsOn: text.id, batchId: "canvas-run" },+ );+ const [m, p] = made.map((g) => getGeneration(g.id)!);+ expect([m.modelId, p.modelId]).toEqual(["oss-face-mosaic", "fuobe-soul"]);+ expect(dependsOn(p.id)).toEqual([text.id]);+ expect(dependsOn(m.id)).toEqual([p.id]);+ expect(made.every((g) => g.batchId === "canvas-run")).toBe(true);+ expect([p.request?.step?.label, m.request?.step?.label]).toEqual(["Portrait · before the face mosaic", "Portrait"]);+ });+it("the GPU graph: SAM 3.1 on the words ('face' by default), the mask grown, a 25 px mosaic under it", async () => {const p = plan({ feature: "image", modelId: "oss-face-mosaic", op: "face-mosaic", inputs: { images: ["/a.png"] } }, "open");expect(p.prompt).toBe("face");@@ -258,7 +463,7 @@ describe("Soul's face mosaic", () => {expect(wf["9"].inputs.mask).toEqual(["5", 0]);});- it("the cloud step: fal's SAM 3.1 masks, all of them kept, and the browser's finish pixelates the picture under them", async () => {+ it("the cloud step: fal's SAM 3.1 masks, all of them in one answer, and the browser's finish for a picture the server can't read", async () => {const m = getModel("sam-3-1-face-mask")!;expect(m.hidden).toBe(true);setSetting("falKey", "fal_test_key_123456");@@ -271,13 +476,68 @@ describe("Soul's face mosaic", () => {}const out = extractOutputs({ masks: [{ url: "https://f/m1.png", content_type: "image/png" }, { url: "https://f/m2.png" }], image: { url: "https://f/preview.png" } }, "face-mosaic");expect(out).toEqual([{ url: "https://f/m1.png", kind: "image", contentType: "image/png", meta: { role: "mask", masks: ["https://f/m1.png", "https://f/m2.png"] } }]);- expect(extractOutputs({ masks: [] }, "face-mosaic")).toEqual([]);- // What the server writes on the step (meta.mosaic) is a finish the browser does once.+ // No face found is an answer (the picture stays as it is); no answer at all is no result.+ expect(extractOutputs({ masks: [] }, "face-mosaic")).toEqual([{ url: "", kind: "image", meta: { role: "mask", masks: [] } }]);+ expect(extractOutputs({ detail: "nope" }, "face-mosaic")).toEqual([]);+ // What the server writes on a picture it couldn't decode (meta.mosaic) is a finish the browser does once.const steps = finishSteps({ kind: "image", meta: { role: "mask", mosaic: { source: "/api/files/a.png", masks: ["/api/files/m1.png"] } } });expect(steps).toEqual({ mosaic: { source: "/api/files/a.png", masks: ["/api/files/m1.png"], scale: tools.MOSAIC_SCALE } });expect(finishSteps({ kind: "image", meta: { finished: true, mosaic: { source: "/a.png", masks: ["/m.png"] } } })).toBeNull();});+ it("the server pixelates fal's answer: a finished picture for the Library, share links, Canvas and API clients", { timeout: 60_000 }, async () => {+ ensureRunner();+ const w = 60;+ const h = 30;+ const picture = saveFile({ data: png(w, h, (x, y) => [x < 30 ? 200 : 20, (x * 7 + y) % 255, 90]), contentType: "image/png", source: "upload" });+ const mask = (x0: number, y0: number) => dataUri(png(w, h, (x, y) => (x >= x0 && x < x0 + 3 && y >= y0 && y < y0 + 3 ? [255, 255, 255] : [0, 0, 0])));+ const answers: Record<string, () => { url: string; kind: "image"; contentType?: string; meta: Record<string, unknown> }[]> = {};+ const poll = mockProvider.poll;+ mockProvider.poll = async (ctx) => {+ const want = ctx.model.id === "sam-3-1-face-mask" ? answers[String(ctx.meta.prompt)] : undefined;+ return want ? { state: "succeeded", outputs: want() } : poll(ctx);+ };+ try {+ const run = async (prompt: string, image: string) => {+ const [g] = createGenerations({ feature: "image", modelId: "sam-3-1-face-mask", op: "face-mosaic", prompt, inputs: { images: [image] } });+ return settled(g.id);+ };+ // Two faces: blocks (0,0) and (2,1) of the 25 px grid.+ answers.faces = () => {+ const m = [mask(3, 3), mask(55, 26)];+ return [{ url: m[0], kind: "image", contentType: "image/png", meta: { role: "mask", masks: m } }];+ };+ const done = await run("faces", picture.url);+ expect(done.status, done.error ?? "").toBe("succeeded");+ const out = done.outputs[0];+ expect(out).toMatchObject({ kind: "image", contentType: "image/png", url: expect.stringMatching(/^\/api\/files\//) });+ expect(out.meta).toMatchObject({ faces: 2, masks: [expect.stringMatching(/^\/api\/files\//), expect.stringMatching(/^\/api\/files\//)] });+ expect(out.meta?.mosaic).toBeUndefined();+ expect(finishSteps(out)).toBeNull();+ const img = decodePng((await readRef(out.url)).data);+ const src = decodePng((await readRef(picture.url)).data);+ const at = (d: Buffer, x: number, y: number) => Array.from(d.subarray((y * w + x) * 4, (y * w + x) * 4 + 3));+ expect(at(img.data, 0, 0)).toEqual(at(img.data, 24, 24));+ expect(at(img.data, 0, 0)).not.toEqual(at(src.data, 0, 0));+ expect(at(img.data, 30, 5)).toEqual(at(src.data, 30, 5));+ expect(at(img.data, 50, 25)).toEqual(at(img.data, 59, 29));+ // No face: the picture as it is, as the GPU graph returns it.+ answers.none = () => [{ url: "", kind: "image", meta: { role: "mask", masks: [] } }];+ const none = await run("none", picture.url);+ expect(none.status, none.error ?? "").toBe("succeeded");+ expect(none.outputs[0].meta).toMatchObject({ faces: 0, masks: [] });+ expect(Array.from(decodePng((await readRef(none.outputs[0].url)).data).data)).toEqual(Array.from(src.data));+ // A picture the server can't decode (a JPEG from another route) is kept with the masks, for the browser to pixelate.+ const jpeg = saveFile({ data: Buffer.from([0xff, 0xd8, 0xff, 0xe0, 0, 16, 74, 70, 73, 70, 0]), contentType: "image/jpeg", source: "upload" });+ const left = await run("faces", jpeg.url);+ expect(left.status, left.error ?? "").toBe("succeeded");+ expect(left.outputs[0].contentType).toBe("image/jpeg");+ expect(finishSteps(left.outputs[0])).toEqual({ mosaic: { source: left.outputs[0].url, masks: left.outputs[0].meta?.masks, scale: tools.MOSAIC_SCALE } });+ } finally {+ mockProvider.poll = poll;+ }+ });+it("pixelates whole blocks wherever a mask touches them, and nothing else", () => {const w = 60;const h = 30;@@ -301,10 +561,20 @@ describe("Soul's face mosaic", () => {expect(at(50, 25)).toEqual(at(59, 29));});- it("the preview prices the Soul picture; the mosaic step is $0.01 in the cloud and free on your GPU", () => {+ it("the preview prices the Soul picture and its mosaic step: $0.01 a picture in the cloud, free on your GPU", () => {expect(estimateCost(getModel("sam-3-1-face-mask")!, {})).toBeCloseTo(0.01, 5);expect(estimateCost(getModel("oss-face-mosaic")!, {})).toBe(0);expect(previewGeneration({ feature: "image", modelId: "oss-face-mosaic", op: "face-mosaic", inputs: { images: ["/a.png"] } }).op).toBe("face-mosaic");+ // The server's preview (CLI, MCP, Assist, Canvas estimates) counts the step, as the composer does.+ setSetting("falKey", "fal_test_key_123456");+ try {+ const look = { feature: "image", modelId: "fuobe-soul", prompt: "a skater", engine: "cloud" as const, params: { numOutputs: 2 } };+ const plain = previewGeneration({ ...look, presetId: "v1-general" }).costUsd!;+ expect(previewGeneration({ ...look, presetId: "v1-pixeletedface" }).costUsd).toBeCloseTo(plain + 0.02, 5);+ expect(previewGeneration({ ...look, presetId: "v1-pixeletedface", postMade: true }).costUsd).toBeCloseTo(plain, 5);+ } finally {+ setSetting("falKey", "");+ }});it("the Image studio knows the mosaic step's models before the full catalog loads, so its price counts the step", async () => {