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.

Catalog: 3D scene models for both engines (MoGe 2 mesh, Marigold depth map)

Claudef32c7a402306
diff --git a/scripts/gen-cloud-models.py b/scripts/gen-cloud-models.py
index 75f1dfcc..532a0358 100644
--- a/scripts/gen-cloud-models.py
+++ b/scripts/gen-cloud-models.py
@@ -706,6 +706,10 @@ model("meshy-7-1-multi", "Meshy 7.1 Multi-view", "Meshy", "meshy", "model3d", "O
controls=[("topology", "Topology")])
model("meshy-rigging", "Meshy Rigging", "Meshy", "meshy", "model3d", "Rig a humanoid GLB with a skeleton, walk and run cycles, or an animation preset",
[("rig-3d", "fal-ai/meshy/rigging")], badges=["new"], pricing=("request", 0.2, "+$0.12 with an animation preset"))
+# Cinema Studio's "Create 3D scene" on the cloud (part 4 §8): a depth map of the whole frame, which the browser
+# turns into a point cloud with the photo's colours. So scene-3d answers with an image on this model.
+model("marigold-depth", "Marigold V2 Depth", "Marigold", "marigold", "image", "A depth map of the whole frame, for the 3D scene your browser builds",
+ [("scene-3d", "fal-ai/marigold-v2")], hidden=True, fixed={"prediction_type": "depth"})
# ----- New video models
model("flux-3-max", "FLUX 3 Max", "Black Forest Labs", "flux", "video",
diff --git a/src/lib/catalog/cloud-models.generated.ts b/src/lib/catalog/cloud-models.generated.ts
index ff6affab..c38224dc 100644
--- a/src/lib/catalog/cloud-models.generated.ts
+++ b/src/lib/catalog/cloud-models.generated.ts
@@ -13018,6 +13018,40 @@ export const CLOUD_MODELS: ModelDef[] = [
"note": "+$0.12 with an animation preset"
}
},
+ {
+ "id": "marigold-depth",
+ "name": "Marigold V2 Depth",
+ "vendor": "Marigold",
+ "family": "marigold",
+ "engine": "cloud",
+ "kind": "image",
+ "tagline": "A depth map of the whole frame, for the 3D scene your browser builds",
+ "routes": [
+ {
+ "op": "scene-3d",
+ "provider": "fal",
+ "endpoint": "fal-ai/marigold-v2",
+ "map": {
+ "prompt": false,
+ "image": "image_url",
+ "seed": "seed",
+ "fixed": {
+ "prediction_type": "depth"
+ }
+ }
+ }
+ ],
+ "options": {
+ "seed": true,
+ "maxImages": 1,
+ "promptless": true
+ },
+ "pricing": {
+ "unit": "image",
+ "usd": 0.03
+ },
+ "hidden": true
+ },
{
"id": "flux-3-max",
"name": "FLUX 3 Max",
diff --git a/src/lib/catalog/models.ts b/src/lib/catalog/models.ts
index dc7abc9f..28d073bf 100644
--- a/src/lib/catalog/models.ts
+++ b/src/lib/catalog/models.ts
@@ -1035,6 +1035,24 @@ const open: ModelDef[] = [
routes: [comfy("image-to-3d", "image-to-3d-hunyuan3d-21")],
options: { seed: true },
}),
+ // Round 4 (r4/cinema-3d): Cinema Studio's "Create 3D scene". The mesh is in the photo's own camera space
+ // (glTF axes, metres), so the viewer starts where the photo was taken.
+ o({
+ id: "oss-scene-moge",
+ name: "MoGe 2 scene",
+ vendor: "Microsoft",
+ family: "moge",
+ kind: "model3d",
+ tagline: "The whole photo as a textured 3D mesh to fly a camera through, plus its depth map · runs on a CPU (about 40 s) · MIT",
+ badges: ["new"],
+ routes: [comfy("scene-3d", "scene-mesh-moge", "MoGe 2 point map → textured GLB of the whole frame + a depth PNG")],
+ options: {
+ sliders: [
+ { param: "resolutionLevel", label: "Detail", min: 0, max: 9, step: 1, default: 9 },
+ { param: "decimation", label: "Mesh thinning (1 = every pixel)", min: 1, max: 4, step: 1, default: 1 },
+ ],
+ },
+ }),
o({
id: "oss-tryon-klein",
name: "FLUX.2 [klein] Try-On",
diff --git a/src/lib/catalog/payload.ts b/src/lib/catalog/payload.ts
index 01072ec7..db616aca 100644
--- a/src/lib/catalog/payload.ts
+++ b/src/lib/catalog/payload.ts
@@ -659,6 +659,17 @@ function model3dOutputs(response: unknown): ExtractedOutput[] {
return mesh ? [{ url: mesh.url, kind: "model3d", contentType: MODEL3D_EXT.test(mesh.url) ? "model/gltf-binary" : mesh.contentType }] : [];
}
+/**
+ * A 3D scene: the whole-scene mesh when the model builds one, else (Marigold's `image`) the depth map that
+ * Cinema Studio turns into a point cloud in the browser, as an image with meta.role "depth".
+ */
+function sceneOutputs(response: unknown): ExtractedOutput[] {
+ const media = extractMedia(response);
+ const depth = media.find((m) => m.kind === "image");
+ if (!depth || media.some((m) => m.kind === "model3d" || /\.(obj|fbx|ply|usdz)(\?|$)/i.test(m.url))) return model3dOutputs(response);
+ return [{ ...depth, meta: { role: "depth" } }];
+}
+
/**
* Gaussian splats (TripoSplat's model_mesh, a .ply unless it says .spz) with meta.format; the cut-out the
* model actually saw is the preview.
@@ -775,9 +786,11 @@ export function extractOutputs(response: unknown, op?: Operation): ExtractedOutp
break;
case "image-to-3d":
case "text-to-3d":
- case "scene-3d":
out = model3dOutputs(response);
break;
+ case "scene-3d":
+ out = sceneOutputs(response);
+ break;
case "splat":
out = splatOutputs(response);
break;
diff --git a/src/server/generations.ts b/src/server/generations.ts
index 39c7cc60..382cce4d 100644
--- a/src/server/generations.ts
+++ b/src/server/generations.ts
@@ -291,7 +291,8 @@ const routeReady = (r: ModelRoute) => (r.provider === "llm" ? llmBackends(r).len
/** What a run produces: colour matching works on images and videos, and fal renders a timeline as a video, so those follow the model. */
export function outputKind(op: Generation["op"], model: { kind: MediaKind }): MediaKind {
- return op === "color-match" || op === "timeline" ? model.kind : OPERATION_OUTPUT[op];
+ // A 3D scene is a mesh on the open engine and a depth map (an image) on the cloud.
+ return op === "color-match" || op === "timeline" || op === "scene-3d" ? model.kind : OPERATION_OUTPUT[op];
}
// Live updates: every write to the table becomes an event (src/server/live.ts). A trashed row
diff --git a/src/server/providers/mock.ts b/src/server/providers/mock.ts
index 2f547810..8d169340 100644
--- a/src/server/providers/mock.ts
+++ b/src/server/providers/mock.ts
@@ -4,6 +4,7 @@ import { cueText, parseCues, type Cue } from "@/lib/cues";
import { OPERATION_OUTPUT, type MediaKind, type Operation } from "@/lib/catalog/types";
import type { ProviderAdapter, RemoteOutput } from "./types";
import { textOutput } from "./llm";
+import { encodePng } from "../png";
import { toDataUri } from "../storage";
/**
@@ -230,6 +231,32 @@ function demoOcr(brief: string): DemoOutput {
const clamp = (n: number, lo: number, hi: number) => Math.max(lo, Math.min(hi, Number.isFinite(n) ? n : lo));
+/**
+ * A depth map like a depth model's PNG (bright = near), 512 px wide in the request's shape: a back wall, a
+ * floor that comes closer toward the bottom of the frame and three rounded subjects standing on it.
+ */
+function demoDepth(prompt: string, aspectRatio: string): DemoOutput {
+ const { w: cw, h: ch } = canvas(aspectRatio);
+ const w = 512;
+ const h = Math.max(16, Math.round((w * ch) / cw));
+ const r = rng(hash(`${prompt}#depth`));
+ const blobs = Array.from({ length: 3 }, (_, i) => ({ x: 0.2 + i * 0.3 + (r() - 0.5) * 0.1, y: 0.5 + r() * 0.2, rx: 0.07 + r() * 0.07, ry: 0.14 + r() * 0.12, near: 0.5 + r() * 0.3 }));
+ const data = Buffer.alloc(w * h * 4);
+ for (let y = 0; y < h; y++)
+ for (let x = 0; x < w; x++) {
+ const u = x / (w - 1);
+ const v = y / (h - 1);
+ let near = 0.12 + 0.68 * Math.max(0, (v - 0.4) / 0.6) ** 1.3;
+ for (const b of blobs) {
+ const d = ((u - b.x) / b.rx) ** 2 + ((v - b.y) / b.ry) ** 2;
+ if (d < 1) near = Math.max(near, b.near + 0.08 * Math.sqrt(1 - d));
+ }
+ const g = Math.round(clamp(near, 0, 1) * 255);
+ data.set([g, g, g, 255], (y * w + x) * 4);
+ }
+ return { url: toDataUri(encodePng({ width: w, height: h, data }), "image/png"), kind: "image", contentType: "image/png", meta: { role: "depth", demo: true } };
+}
+
function demoOutputs(op: Operation | undefined, kind: MediaKind, prompt: string, ar: string, meta: Record<string, unknown>): DemoOutput[] {
// The prompt falls back to the op name when a step has none.
const brief = prompt === op ? "" : prompt;
@@ -264,9 +291,13 @@ function demoOutputs(op: Operation | undefined, kind: MediaKind, prompt: string,
{ url: "sample:demo-model.glb", kind: "model3d", contentType: "model/gltf-binary", meta: { demo: true, format: "glb" } },
{ url: "sample:demo-turntable.mp4", kind: "video", contentType: "video/mp4", meta: { demo: true, turntable: true } },
];
- // Round 4. A scene, a splat and a rig all come back as the demo mesh (a real splat is a .ply or .spz).
- case "scene-3d":
- return [{ url: "sample:demo-model.glb", kind: "model3d", contentType: "model/gltf-binary", meta: { demo: true, format: "glb", scene: true } }];
+ // Round 4. A splat and a rig come back as the demo mesh (a real splat is a .ply or .spz). A scene is the
+ // mesh and its depth map on the open engine (MoGe), the depth map alone on the cloud (Marigold).
+ case "scene-3d": {
+ const depth = demoDepth(brief, ar);
+ if (kind === "image") return [depth];
+ return [{ url: "sample:demo-model.glb", kind: "model3d", contentType: "model/gltf-binary", meta: { demo: true, format: "glb", scene: true, role: "scene" } }, depth];
+ }
case "splat":
return [{ url: "sample:demo-model.glb", kind: "model3d", contentType: "model/gltf-binary", meta: { demo: true, format: "glb", splat: true } }];
case "rig-3d":
@@ -325,8 +356,9 @@ export const mockProvider: ProviderAdapter = {
meta: {
startedAt: Date.now(),
op: route.op,
- // Colour matching keeps the input's kind (an image or a video); a timeline is audio or (fal) a video.
- kind: route.op === "color-match" || route.op === "timeline" ? model.kind : OPERATION_OUTPUT[route.op],
+ // Colour matching keeps the input's kind (an image or a video); a timeline is audio or (fal) a video;
+ // a 3D scene is a mesh (open) or a depth map (cloud).
+ kind: route.op === "color-match" || route.op === "timeline" || route.op === "scene-3d" ? model.kind : OPERATION_OUTPUT[route.op],
prompt: input.prompt ?? route.op,
aspectRatio: input.aspectRatio ?? "1:1",
count: Math.max(1, Math.min(4, input.numOutputs ?? 1)),
diff --git a/tests/scene3d-provider.test.ts b/tests/scene3d-provider.test.ts
new file mode 100644
index 00000000..3cae2ffa
--- /dev/null
+++ b/tests/scene3d-provider.test.ts
@@ -0,0 +1,138 @@
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { afterAll, describe, expect, it } from "vitest";
+import type { ManifestWorkflow } from "@/lib/comfy";
+import type { ModelDef, ModelRoute } from "@/lib/catalog/types";
+
+/** Cinema Studio's "Create 3D scene" on both engines: the catalog models, the ComfyUI binding and the outputs. */
+
+const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-scene3d-"));
+process.env.FUOBE_DATA_DIR = dir;
+process.env.COMFYUI_URL = "http://comfy.test:8188";
+
+const { collectOutputs, getWorkflow, prepareWorkflow } = await import("@/server/providers/comfyui");
+const { getModel } = await import("@/lib/catalog");
+const { buildPayload, extractOutputs } = await import("@/lib/catalog/payload");
+const { outputKind } = await import("@/server/generations");
+const { mockProvider } = await import("@/server/providers/mock");
+const { decodePng } = await import("@/server/png");
+
+afterAll(() => fs.rmSync(dir, { recursive: true, force: true }));
+
+const manifestOf = (id: string): ManifestWorkflow => getWorkflow(id).manifest;
+
+async function prepare(extra: Record<string, unknown> = {}) {
+ const uploads: string[] = [];
+ const res = await prepareWorkflow("scene-mesh-moge", { prompt: "", images: ["still.png"], extra }, {
+ generationId: "gen-scene",
+ op: "scene-3d",
+ upload: async (_d, _t, name) => {
+ uploads.push(name);
+ return `up_${name}`;
+ },
+ });
+ return { ...res, uploads };
+}
+
+describe("open engine: MoGe 2 scene (scene-mesh-moge)", () => {
+ it("is a catalog model on the validated workflow, with no prompt", () => {
+ const m = getModel("oss-scene-moge")!;
+ expect(m.engine).toBe("open");
+ expect(m.kind).toBe("model3d");
+ expect(m.routes).toEqual([expect.objectContaining({ op: "scene-3d", provider: "comfyui", endpoint: "scene-mesh-moge" })]);
+ const w = manifestOf("scene-mesh-moge");
+ expect(w.validated).toBe(true);
+ expect(w.capability).toBe("scene-3d");
+ expect(m.options.sliders?.map((s) => s.param)).toEqual(["resolutionLevel", "decimation"]);
+ });
+
+ it("binds the still, the file prefix of both outputs and the manifest's defaults", async () => {
+ const { workflow, meta } = await prepare();
+ expect(workflow["1"].inputs.image).toBe("still.png");
+ expect(workflow["9"].inputs.filename_prefix).toBe("fuobe/gen-scene");
+ expect(workflow["11"].inputs.filename_prefix).toBe("fuobe/gen-scene");
+ expect(workflow["6"].inputs.model_name).toBe("moge_2_vitl_normal_fp16.safetensors");
+ expect(workflow["7"].inputs).toMatchObject({ resolution_level: 9, fov_x_degrees: 0 });
+ expect(workflow["8"].inputs).toMatchObject({ decimation: 1, texture: true });
+ expect(meta.workflowId).toBe("scene-mesh-moge");
+ });
+
+ it("takes detail, thinning and a known field of view from params.extra", async () => {
+ const { workflow } = await prepare({ resolutionLevel: 6, decimation: 2, fovX: 73.7 });
+ expect(workflow["7"].inputs).toMatchObject({ resolution_level: 6, fov_x_degrees: 73.7 });
+ expect(workflow["8"].inputs.decimation).toBe(2);
+ });
+
+ it("asks for the still when there is none", async () => {
+ await expect(prepareWorkflow("scene-mesh-moge", { prompt: "", images: [] }, { generationId: "g", op: "scene-3d", upload: async () => "x" })).rejects.toThrow(/Add an image/);
+ });
+
+ it("returns the scene GLB first and the depth PNG second, each with its role", () => {
+ const file = (filename: string) => ({ filename, subfolder: "fuobe", type: "output" });
+ const outs = collectOutputs(
+ { status: { status_str: "success", completed: true }, outputs: { "11": { images: [file("gen-scene_00001_.png")] }, "9": { "3d": [file("gen-scene_00001_.glb")] } } },
+ manifestOf("scene-mesh-moge"),
+ );
+ expect(outs.map((o) => [o.kind, o.contentType, o.meta?.role])).toEqual([
+ ["model3d", "model/gltf-binary", "scene"],
+ ["image", undefined, "depth"],
+ ]);
+ });
+});
+
+describe("cloud: Marigold V2 depth (fal-ai/marigold-v2)", () => {
+ const m = getModel("marigold-depth") as ModelDef;
+ const route = m.routes[0] as ModelRoute;
+
+ it("is a hidden helper that answers scene-3d with an image at $0.03", () => {
+ expect(m.hidden).toBe(true);
+ expect(m.kind).toBe("image");
+ expect(route).toMatchObject({ op: "scene-3d", provider: "fal", endpoint: "fal-ai/marigold-v2" });
+ expect(m.pricing).toMatchObject({ unit: "image", usd: 0.03 });
+ expect(outputKind("scene-3d", m)).toBe("image");
+ expect(outputKind("scene-3d", getModel("oss-scene-moge")!)).toBe("model3d");
+ });
+
+ it("sends the still and always asks for depth (not normals or albedo)", () => {
+ const body = buildPayload(route.map!, { prompt: "", images: ["https://fal.test/still.png"], seed: 3 });
+ expect(body).toEqual({ image_url: "https://fal.test/still.png", seed: 3, prediction_type: "depth" });
+ });
+
+ it("reads the depth map as an image with role depth, and a mesh answer as the 3D model", () => {
+ const depth = extractOutputs({ image: { url: "https://fal.test/depth.png", content_type: "image/png", width: 1024, height: 576 }, seed: 3 }, "scene-3d");
+ expect(depth).toEqual([{ url: "https://fal.test/depth.png", kind: "image", contentType: "image/png", meta: { role: "depth" } }]);
+ const mesh = extractOutputs({ model_glb: { url: "https://fal.test/scene.glb" }, image: { url: "https://fal.test/preview.png" } }, "scene-3d");
+ expect(mesh[0]).toMatchObject({ url: "https://fal.test/scene.glb", kind: "model3d" });
+ });
+});
+
+describe("demo mode", () => {
+ async function demo(model: ModelDef) {
+ const route = model.routes[0];
+ const sub = await mockProvider.submit({ generationId: "g", model, route, input: { prompt: "", images: ["still.png"], aspectRatio: "16:9" } });
+ const meta = { ...sub.meta, startedAt: 0 };
+ const res = await mockProvider.poll({ externalId: sub.externalId, meta, route, model, createdAt: 0 });
+ if (res.state !== "succeeded") throw new Error(res.state);
+ return res.outputs;
+ }
+
+ it("makes a 16:9 depth map (bright = near, the floor closest at the bottom) for the cloud", async () => {
+ const outs = await demo(getModel("marigold-depth")!);
+ expect(outs).toHaveLength(1);
+ expect(outs[0]).toMatchObject({ kind: "image", contentType: "image/png", meta: { role: "depth", demo: true } });
+ const png = decodePng(Buffer.from(outs[0].url.split(",")[1], "base64"));
+ expect(png.width).toBe(512);
+ expect(png.height).toBe(288);
+ const grey = (x: number, y: number) => png.data[(y * png.width + x) * 4];
+ expect(grey(4, png.height - 1)).toBeGreaterThan(grey(4, 0) + 100);
+ });
+
+ it("makes the demo mesh and its depth map for the open engine", async () => {
+ const outs = await demo(getModel("oss-scene-moge")!);
+ expect(outs.map((o) => [o.kind, o.meta?.role])).toEqual([
+ ["model3d", "scene"],
+ ["image", "depth"],
+ ]);
+ });
+});