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
Image to 3D: tests for Idol 3D's graph, settings, outputs, licence and account rules
Claudeccf9ff4cd6ad
diff --git a/tests/idol.test.ts b/tests/idol.test.tsnew file mode 100644index 00000000..5f1e11db--- /dev/null+++ b/tests/idol.test.ts@@ -0,0 +1,122 @@+import fs from "node:fs";+import path from "node:path";+import { describe, expect, it } from "vitest";+import { APPS, MODELS, getModel } from "@/lib/catalog";+import { modelChoices } from "@/lib/catalog/canvas";+import type { Manifest } from "@/lib/comfy";+import { licenceTerms, workflowLicence } from "@/lib/licences";++/**+ * Idol 3D (idol-1, docs/research/idol-9.md §5.5): the library entry, the graph (a copy of TripoSplat's with Idol's+ * files, its reference sampler, the core-node photo crop and the haze threshold), its licence notice and its name.+ */++const root = process.cwd();+const manifest = JSON.parse(fs.readFileSync(path.join(root, "workflows", "comfyui", "manifest.json"), "utf8")) as Manifest;+const entry = manifest.workflows.find((w) => w.id === "image-to-splat-idol")!;+type Node = { class_type: string; inputs: Record<string, unknown> };+const graph = JSON.parse(fs.readFileSync(path.join(root, "workflows", "comfyui", "image-to-splat-idol.json"), "utf8")) as Record<string, Node>;+const tripo = JSON.parse(fs.readFileSync(path.join(root, "workflows", "comfyui", "image-to-splat-triposplat.json"), "utf8")) as Record<string, Node>;+const NYNXZ = "https://huggingface.co/nynxz/Idol/resolve/c718f2b1b95b353edd07d17e845719fc10880a44";++describe("image-to-splat-idol: the manifest entry", () => {+ it("is a splat on core nodes with Best's defaults, the photo crop off and 8 GB", () => {+ expect(entry).toMatchObject({ capability: "splat", customNodes: [], vramGb: 8, limits: { maxGaussians: 1048576 } });+ expect(entry.defaults).toMatchObject({ splatFormat: "spz", cutout: true, photoCrop: false, steps: 50, cfg: 4, numGaussians: 262144 });+ expect(Object.keys(entry.bindings).sort()).toEqual(["cfg", "cutout", "filenamePrefix", "image", "numGaussians", "orbitFrames", "photoCrop", "sampler", "seed", "splatFormat", "steps"]);+ expect(entry.bindings.sampler).toEqual([{ node: "88:6", input: "sampler_name" }]);+ expect(entry.bindings.photoCrop).toEqual([{ node: "88:104", input: "switch" }]);+ expect(entry.bindings.seed).toEqual([+ { node: "88:6", input: "seed" },+ { node: "88:55", input: "seed" },+ ]);+ });++ it("needs Idol's two pinned files and the three it shares with TripoSplat", () => {+ const models = Object.fromEntries(entry.models.map((m) => [m.file, m]));+ expect(Object.fromEntries(entry.models.map((m) => [m.file, m.sizeGb]))).toEqual({+ "idol_fp16.safetensors": 0.74,+ "idol_decoder_fp16.safetensors": 0.58,+ "dino_v3_vit_h.safetensors": 1.68,+ "flux2-vae.safetensors": 0.34,+ "birefnet.safetensors": 0.44,+ });+ expect(models["idol_fp16.safetensors"].url).toBe(`${NYNXZ}/diffusion_models/idol_fp16.safetensors`);+ expect(models["idol_decoder_fp16.safetensors"].url).toBe(`${NYNXZ}/vae/idol_decoder_fp16.safetensors`);+ const pins = JSON.parse(fs.readFileSync(path.join(root, "workflows", "comfyui", "model-pins.json"), "utf8")) as Record<string, { sizeBytes: number; sha256: string }>;+ expect(pins[`${NYNXZ}/diffusion_models/idol_fp16.safetensors`]).toMatchObject({ sizeBytes: 741107210, sha256: "cf452146f78e23a0d34be8f9f79bcde642b9a40ef493046c8e9d5f79096f6dd0" });+ expect(pins[`${NYNXZ}/vae/idol_decoder_fp16.safetensors`]).toMatchObject({ sizeBytes: 576148658, sha256: "c511d99eb668ec4b06d883cb6e43770bc35e3864e16e7058e8d6211ba5c509aa" });+ });++ it("is in the GPU check's index and validated", () => {+ const req = JSON.parse(fs.readFileSync(path.join(root, "workflows", "comfyui", "requirements.json"), "utf8")) as { workflows: Record<string, { files: string[]; packs: object }> };+ expect(req.workflows["image-to-splat-idol"].files).toEqual(["background_removal/birefnet.safetensors", "clip_vision/dino_v3_vit_h.safetensors", "diffusion_models/idol_fp16.safetensors", "vae/flux2-vae.safetensors", "vae/idol_decoder_fp16.safetensors"]);+ expect(req.workflows["image-to-splat-idol"].packs).toEqual({});+ const state = JSON.parse(fs.readFileSync(path.join(root, "scripts", "comfy", "validation-state.json"), "utf8")) as Record<string, { validated: boolean }>;+ expect(state["image-to-splat-idol"].validated).toBe(true);+ });+});++describe("image-to-splat-idol: the graph", () => {+ it("loads Idol's files and samples at its reference settings", () => {+ expect(graph["88:16"].inputs).toMatchObject({ unet_name: "idol_fp16.safetensors", weight_dtype: "default" });+ expect(graph["88:11"].inputs.vae_name).toBe("idol_decoder_fp16.safetensors");+ expect(graph["88:6"].inputs).toMatchObject({ steps: 50, cfg: 4, sampler_name: "euler", scheduler: "simple", denoise: 1 });+ expect(Object.values(graph).some((n) => n.class_type === "ModelSamplingSD3")).toBe(false);+ });++ it("drops the haze from the orbit video only", () => {+ expect(graph["75"].inputs.opacity_threshold).toBe(0.05);+ expect(graph["92"].inputs.splat).toEqual(["88:55", 0]);+ });++ it("crops a photo looser on core nodes, behind a switch that is off by default", () => {+ expect(graph["88:101"]).toMatchObject({ class_type: "ImageScale", inputs: { image: ["88:2", 0], upscale_method: "lanczos", width: 720, height: 720, crop: "disabled" } });+ expect(graph["88:102"]).toMatchObject({ class_type: "EmptyImage", inputs: { width: 1024, height: 1024, batch_size: 1, color: 0 } });+ expect(graph["88:103"]).toMatchObject({ class_type: "ImageCompositeMasked", inputs: { destination: ["88:102", 0], source: ["88:101", 0], x: 152, y: 152, resize_source: false } });+ expect(graph["88:104"]).toMatchObject({ class_type: "ComfySwitchNode", inputs: { switch: false, on_false: ["88:2", 0], on_true: ["88:103", 0] } });+ expect(graph["88:24"].inputs.image).toEqual(["88:104", 0]);+ // The object spans 720 / 1.2 = 600 px on the 1024 canvas, as Idol's "real" crop (1024 / 1.7 ≈ 602 px) does.+ expect(Math.round(720 / 1.2)).toBe(600);+ expect(152 * 2 + 720).toBe(1024);+ });++ it("keeps everything else as TripoSplat's graph has it", () => {+ const changed = new Set(["88:16", "88:11", "88:6", "75", "88:24", "88:101", "88:102", "88:103", "88:104"]);+ for (const [id, node] of Object.entries(tripo)) {+ expect(graph[id]?.class_type, id).toBe(node.class_type);+ if (!changed.has(id) && !["51", "42"].includes(id)) expect(graph[id].inputs, id).toEqual(node.inputs);+ }+ expect(Object.keys(graph).filter((id) => !tripo[id]).sort()).toEqual(["88:101", "88:102", "88:103", "88:104"]);+ });+});++describe("Idol 3D: licence, name and where it shows", () => {+ it("names Apache-2.0, the TripoSplat MIT attribution and the DINOv3 notice", () => {+ const text = workflowLicence(entry);+ expect(text).toMatch(/^Apache-2.0/);+ expect(text).toMatch(/TripoSplat architecture \(MIT/);+ expect(licenceTerms(text).notices).toEqual(["Built with DINOv3"]);+ // The same catches as TripoSplat's (the DINOv3 License's trade-control terms).+ const triposplat = manifest.workflows.find((w) => w.id === "image-to-splat-triposplat")!;+ expect(licenceTerms(text).flags).toEqual(licenceTerms(workflowLicence(triposplat)).flags);+ });++ it("is the only model or app called Idol 3D (one per engine), apart from the K-pop Idol app", () => {+ expect(MODELS.filter((m) => m.name === "Idol 3D").map((m) => [m.id, m.engine])).toEqual(+ expect.arrayContaining([+ ["oss-idol", "open"],+ ["idol-3d", "cloud"],+ ]),+ );+ expect(MODELS.filter((m) => m.name === "Idol 3D")).toHaveLength(2);+ expect(APPS.filter((a) => a.name === "Idol 3D")).toEqual([]);+ expect(APPS.some((a) => a.name === "Idol")).toBe(true);+ });++ it("is offered by a Canvas 3D model node, with its sliders", () => {+ const ids = modelChoices({ type: "model", data: { mediaKind: "model3d" } } as never).map((m) => m.id);+ expect(ids).toEqual(expect.arrayContaining(["oss-idol", "idol-3d"]));+ expect(getModel("oss-idol")!.options?.sliders?.map((s) => s.param)).toEqual(["numGaussians", "steps"]);+ });+});diff --git a/tests/model3d.test.ts b/tests/model3d.test.tsindex d0331b30..33bbfce7 100644--- a/tests/model3d.test.ts+++ b/tests/model3d.test.ts@@ -337,6 +337,89 @@ describe("open engine: TripoSplat (image-to-splat-triposplat)", () => {});});+describe("Idol 3D (image-to-splat-idol on the open engine, speridlabs/idol on fal)", () => {+ const file = (filename: string) => ({ filename, subfolder: "fuobe", type: "output" });++ it("routes oss-idol to its graph and idol-3d to fal; TripoSplat stays first on both engines", () => {+ expect(getModel("oss-idol")!.routes).toEqual([expect.objectContaining({ op: "splat", provider: "comfyui", endpoint: "image-to-splat-idol" })]);+ expect(getModel("idol-3d")!.routes).toEqual([expect.objectContaining({ op: "splat", provider: "fal", endpoint: "speridlabs/idol" })]);+ expect(m3d.MODELS_3D.splat.open.map((m) => m.id)).toEqual(["oss-triposplat", "oss-idol"]);+ expect(m3d.MODELS_3D.splat.cloud.map((m) => m.id)).toEqual(["triposplat", "idol-3d"]);+ expect(m3d.modeOf("oss-idol")).toEqual({ mode: "splat", engine: "open" });+ expect(m3d.modeOf("idol-3d")).toEqual({ mode: "splat", engine: "cloud" });+ expect(m3d.ALL_MODELS_3D.some((m) => m.id === "oss-idol")).toBe(true);+ // Idol encodes with DINOv3 on fal too; cloud TripoSplat is never labelled Idol.+ expect(m3d.CLOUD_NOTICES["idol-3d"]).toEqual(["Built with DINOv3"]);+ expect(getModel("triposplat")!.name).toBe("TripoSplat");+ expect(plan(m3d.model3dRequest({ engine: "cloud", mode: "splat", photo, modelId: "idol-3d" })).model.id).toBe("idol-3d");+ });++ it("sends Best by default and Quick look when asked; TripoSplat's requests are unchanged", () => {+ const open = (more: Partial<Parameters<typeof m3d.model3dRequest>[0]>) => m3d.model3dRequest({ engine: "open", mode: "splat", photo, modelId: "oss-idol", ...more });+ expect(open({}).params).toEqual({ extra: { steps: 50, sampler: "euler", cfg: 4, numGaussians: 262144, photoCrop: false } });+ expect(open({ quality: "quick", photoCrop: true }).params).toEqual({ extra: { steps: 20, sampler: "dpmpp_2m", cfg: 4, numGaussians: 65536, photoCrop: true } });+ expect(m3d.IDOL_PRESETS).toEqual({ best: { steps: 50, sampler: "euler", cfg: 4, numGaussians: 262144 }, quick: { steps: 20, sampler: "dpmpp_2m", cfg: 4, numGaussians: 65536 } });+ // fal takes the steps, the Gaussians and the kind of picture; its guidance stays its own (Idol's weight 3).+ expect(m3d.model3dRequest({ engine: "cloud", mode: "splat", photo, modelId: "idol-3d", quality: "quick", photoCrop: true }).params).toEqual({+ extra: { num_inference_steps: 20, num_gaussians: 65536, image_type: "real" },+ });+ // The Idol settings never reach TripoSplat.+ expect(m3d.model3dRequest({ engine: "open", mode: "splat", photo, quality: "quick", photoCrop: true })).toEqual({ feature: "image-to-3d", modelId: "oss-triposplat", op: "splat", inputs: { images: [photo] } });+ expect(m3d.model3dRequest({ engine: "cloud", mode: "splat", photo, quality: "quick" })).toEqual({ feature: "image-to-3d", modelId: "triposplat", op: "splat", inputs: { images: [photo] } });+ });++ it("binds the photo, the Gaussians, steps / cfg / sampler, the seed on both nodes and the photo crop; cut-out on, .spz", async () => {+ const extra = m3d.model3dRequest({ engine: "open", mode: "splat", photo, modelId: "oss-idol", quality: "quick", photoCrop: true }).params!.extra!;+ const { workflow } = await prepareWorkflow("image-to-splat-idol", { prompt: "", images: ["p.png"], seed: 7, extra }, { generationId: "gen-idol", op: "splat", upload: async () => "x" });+ expect(workflow["99"].inputs.image).toBe("p.png");+ expect(workflow["88:55"].inputs).toMatchObject({ num_gaussians: 65536, seed: 7 });+ expect(workflow["88:6"].inputs).toMatchObject({ steps: 20, cfg: 4, sampler_name: "dpmpp_2m", seed: 7 });+ expect(workflow["88:104"].inputs.switch).toBe(true);+ expect(workflow["88:35"].inputs.switch).toBe(true);+ expect(workflow["92"].inputs.format).toBe("spz");+ const best = await prepareWorkflow("image-to-splat-idol", { prompt: "", images: ["p.png"] }, { generationId: "gen-idol2", op: "splat", upload: async () => "x" });+ expect(best.workflow["88:6"].inputs).toMatchObject({ steps: 50, cfg: 4, sampler_name: "euler" });+ expect(best.workflow["88:104"].inputs.switch).toBe(false);+ });++ it("gives the .spz as the splat and the orbit as the turntable; a chain into a video slot takes the orbit", () => {+ const outs = collectOutputs(+ { status: { status_str: "success", completed: true }, outputs: { "51": { "3d": [file("gen-idol_00001_.spz")] }, "42": { images: [file("gen-idol_00001_.mp4")], animated: [true] } } },+ getWorkflow("image-to-splat-idol").manifest,+ );+ expect(outs.map((o) => [o.kind, o.contentType, o.meta])).toEqual([+ ["model3d", "model/x-spz", { role: "splat", format: "spz" }],+ ["video", undefined, { role: "turntable" }],+ ]);+ expect(gens.pickOutput(outs as never, { slot: "video" } as never)?.kind).toBe("video");+ });++ it("fal: the .ply splat with the cut-out as its preview and the point-cloud GLB as a download", () => {+ const route = getModel("idol-3d")!.routes[0];+ expect(buildPayload(route.map!, { prompt: "", images: ["https://fal.test/p.png"], seed: 3, extra: { num_inference_steps: 20, num_gaussians: 65536, image_type: "real" } })).toEqual({+ image_url: "https://fal.test/p.png",+ seed: 3,+ num_inference_steps: 20,+ num_gaussians: 65536,+ image_type: "real",+ });+ const outs = extractOutputs(+ {+ model_mesh: { url: "https://fal.media/s.ply", content_type: "application/octet-stream" },+ model_glb: { url: "https://fal.media/p.glb" },+ preprocessed_image: { url: "https://fal.media/cut.png" },+ camera: { yaw: 0.1, pitch: 0.2, radius: 2, fov: 40 },+ num_gaussians: 65536,+ seed: 3,+ timings: {},+ },+ "splat",+ );+ expect(outs).toEqual([{ url: "https://fal.media/s.ply", kind: "model3d", contentType: "model/ply", meta: { format: "ply", preview: "https://fal.media/cut.png", formats: { points: "https://fal.media/p.glb" } } }]);+ expect(estimateCost(getModel("idol-3d")!, {}, 1, "splat")).toBe(0.1);+ });+});+describe("open engine: text to 3D as a Qwen-Image 2.1 still, then TRELLIS.2", () => {async function settle(id: string, ms = 40_000) {const until = Date.now() + ms;