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.

Image to 3D: pick Idol 3D for a splat, with Best or Quick look and a looser crop for photos

Claude3347c79c62da
diff --git a/src/components/model3d/model3d-studio.tsx b/src/components/model3d/model3d-studio.tsx
index 0f94f30a..28301d7b 100644
--- a/src/components/model3d/model3d-studio.tsx
+++ b/src/components/model3d/model3d-studio.tsx
@@ -9,6 +9,7 @@ import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { Skeleton } from "@/components/ui/skeleton";
+import { Switch } from "@/components/ui/switch";
import { Textarea } from "@/components/ui/textarea";
import { FailedTile, PendingTile } from "@/components/studio/feed";
import { MediaSlot, type SlotValue } from "@/components/studio/media-slot";
@@ -17,6 +18,7 @@ import { Panel, ToolHero, ToolShell } from "@/components/av/tool-shell";
import { SelfHostNote } from "@/components/self-host-note";
import { useCreateGeneration, useEngine, useGenerations, useHydrated, useLikelyVisitor, useModelAccess, useStatus } from "@/lib/api";
import {
+ IDOL_QUALITIES,
MAX_3D_PROMPT,
MODEL3D_FEATURE,
MODEL3D_MODES,
@@ -25,10 +27,12 @@ import {
SIDE_LABELS,
SIDES_HINT,
VIEW_SIDES,
+ isIdol,
model3dBlocker,
model3dFor,
model3dRequest,
modeOf,
+ type IdolQuality,
type Model3dInput,
type Model3dMode,
type ViewSide,
@@ -78,6 +82,59 @@ function UrlModel({ onModel, onMode, onRig }: { onModel: (mode: Model3dMode, eng
return null;
}
+/**
+ * Idol 3D's settings: Best or Quick look (labelled by steps and Gaussians), and "It's a photo", which gives the object
+ * Idol's looser crop.
+ */
+function IdolSettings({ quality, onQuality, photo, onPhoto }: { quality: IdolQuality; onQuality: (q: IdolQuality) => void; photo: boolean; onPhoto: (v: boolean) => void }) {
+ const refs = useRef<(HTMLButtonElement | null)[]>([]);
+ const move = (from: number, by: number) => {
+ const i = (from + by + IDOL_QUALITIES.length) % IDOL_QUALITIES.length;
+ onQuality(IDOL_QUALITIES[i].id);
+ refs.current[i]?.focus();
+ };
+ return (
+ <div className="mt-3 space-y-3">
+ <div>
+ <div role="radiogroup" aria-label="Quality" className="grid grid-cols-2 gap-0.5 rounded-full bg-muted p-0.5">
+ {IDOL_QUALITIES.map((q, i) => (
+ <button
+ key={q.id}
+ ref={(el) => {
+ refs.current[i] = el;
+ }}
+ type="button"
+ role="radio"
+ aria-checked={quality === q.id}
+ tabIndex={quality === q.id ? 0 : -1}
+ onClick={() => onQuality(q.id)}
+ onKeyDown={(e) => {
+ if (e.key === "ArrowRight" || e.key === "ArrowDown") {
+ e.preventDefault();
+ move(i, 1);
+ } else if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
+ e.preventDefault();
+ move(i, -1);
+ }
+ }}
+ className={cn("h-8 rounded-full px-3 text-[13px] font-medium", quality === q.id ? "bg-background text-foreground shadow-soft" : "text-muted-foreground hover:text-foreground")}
+ >
+ {q.label}
+ </button>
+ ))}
+ </div>
+ <p className="mt-1.5 text-[12px] text-muted-foreground">{IDOL_QUALITIES.find((q) => q.id === quality)?.hint}</p>
+ </div>
+ <div className="flex items-center justify-between gap-3">
+ <Label htmlFor="m3d-idol-photo" className="text-[13px] font-normal">
+ It&apos;s a photo (looser crop)
+ </Label>
+ <Switch id="m3d-idol-photo" checked={photo} onCheckedChange={onPhoto} />
+ </div>
+ </div>
+ );
+}
+
/** The five modes as one row of pills (wrapping on a phone); arrow keys move between them. */
function ModePicker({ mode, onChange }: { mode: Model3dMode; onChange: (m: Model3dMode) => void }) {
const refs = useRef<(HTMLButtonElement | null)[]>([]);
@@ -142,6 +199,17 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
const hydrated = useHydrated();
const engineKnown = statusKnown && hydrated;
const [photo, setPhoto] = useState<SlotValue | null>(null);
+ // Idol 3D (Splat): Best or Quick look, and whether the picture is a photo. A picture uploaded or dropped here is taken
+ // for a photo; one picked from the library (a Fuobe result, usually) for a render or a generated image.
+ const [idolQuality, setIdolQuality] = useState<IdolQuality>("best");
+ const [idolPhoto, setIdolPhoto] = useState(true);
+ const takePhoto = (v: SlotValue | null) => {
+ setPhoto(v);
+ if (v && v.ref !== photo?.ref) {
+ if (v.uploading) setIdolPhoto(true);
+ else if (!photo?.uploading) setIdolPhoto(false);
+ }
+ };
const [views, setViews] = useState<Partial<Record<ViewSide, SlotValue | null>>>({});
const [text, setText] = useState("");
const [object, setObject] = useState("");
@@ -161,7 +229,16 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
const wanted = picked[`${mode}:${engine}`];
const modelId = model3dFor(mode, engine, wanted && choices.some((m) => m.id === wanted) ? wanted : choices[0]?.id);
const sides = Object.fromEntries(VIEW_SIDES.flatMap((s) => (views[s] ? [[s, views[s]!.ref]] : []))) as Partial<Record<ViewSide, string>>;
- const input: Model3dInput = { engine, mode, modelId: modelId ?? undefined, photo: photo?.ref, views: sides, prompt: mode === "text" ? text : mode === "objects" ? object : undefined };
+ const idol = mode === "splat" && isIdol(modelId);
+ const input: Model3dInput = {
+ engine,
+ mode,
+ modelId: modelId ?? undefined,
+ photo: photo?.ref,
+ views: sides,
+ prompt: mode === "text" ? text : mode === "objects" ? object : undefined,
+ ...(idol && { quality: idolQuality, photoCrop: idolPhoto }),
+ };
const uploading = !!photo?.uploading || VIEW_SIDES.some((s) => views[s]?.uploading);
// A guest or an account reads why the button is off, not a step on an upload that is off too.
const blocker = visitor ? "Image to 3D isn't available here" : (model3dBlocker(input) ?? (uploading ? "Uploading…" : null));
@@ -255,7 +332,7 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
<MediaDrop
kind="image"
value={photo}
- onChange={setPhoto}
+ onChange={takePhoto}
title={mode === "objects" ? "Add a photo" : "Add a photo of the object"}
hint={mode === "objects" ? "A room, a shelf, a street: anything with the object in it" : "One object, plain background, well lit"}
compact
@@ -318,6 +395,7 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
{!licence && info[modelId]?.notices.length > 0 && <p className="text-[12px] font-medium">{info[modelId].notices.join(" · ")}</p>}
{licence && licence.notices.length > 0 && <p className="text-[12px] text-muted-foreground">{licence.notices.join(" · ")}</p>}
</div>
+ {idol && <IdolSettings quality={idolQuality} onQuality={setIdolQuality} photo={idolPhoto} onPhoto={setIdolPhoto} />}
<Button size="lg" className={cn("mt-4 w-full rounded-full", blocker && "bg-muted text-muted-foreground hover:bg-muted")} onClick={go} disabled={create.isPending || visitor}>
{create.isPending ? <Loader2 className="size-4 animate-spin" /> : <Box className="size-4" />} {mode === "splat" ? "Make the splat" : "Make it 3D"}
</Button>
@@ -325,13 +403,17 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
{visitor ? blocker : <>{blocker ? `${blocker} · ` : ""}{preview.isError ? (preview.error as Error).message : (price ?? "Working out the price…")}</>}
</p>
<p className="mt-1 text-[12px] text-muted-foreground">
- {mode === "splat"
+ {idol
? engine === "open"
- ? "Cuts the subject out and comes with an orbit video."
- : "Cuts the subject out, ready to download."
- : engine === "open"
- ? "Comes with a turntable video of your model."
- : "Download your model, or record a turntable right here."}
+ ? "Idol cuts the object out, builds the splat and renders an orbit video on your GPU. One object per picture."
+ : "Idol cuts the object out and builds the splat, ready to download. One object per picture."
+ : mode === "splat"
+ ? engine === "open"
+ ? "Cuts the subject out and comes with an orbit video."
+ : "Cuts the subject out, ready to download."
+ : engine === "open"
+ ? "Comes with a turntable video of your model."
+ : "Download your model, or record a turntable right here."}
</p>
</>
)}
diff --git a/src/lib/av/model3d.ts b/src/lib/av/model3d.ts
index fa64fdc5..a9f08112 100644
--- a/src/lib/av/model3d.ts
+++ b/src/lib/av/model3d.ts
@@ -55,8 +55,15 @@ export const MODELS_3D: Record<Model3dMode, Record<Engine, Model3dChoice[]>> = {
open: [],
},
splat: {
- cloud: [{ id: "triposplat", note: "A soft, photoreal 3D capture · ≈ $0.05" }],
- open: [{ id: "oss-triposplat", note: "A soft, photoreal 3D capture, with an orbit video" }],
+ cloud: [
+ { id: "triposplat", note: "A soft, photoreal 3D capture · ≈ $0.05" },
+ { id: "idol-3d", note: "One object from one picture · ≈ $0.10" },
+ ],
+ // TripoSplat stays the default until Idol 3D is compared with it side by side (idol-3).
+ open: [
+ { id: "oss-triposplat", note: "A soft, photoreal 3D capture, with an orbit video" },
+ { id: "oss-idol", note: "One object from one picture, with an orbit video" },
+ ],
},
};
@@ -66,7 +73,41 @@ export const MODELS_3D: Record<Model3dMode, Record<Engine, Model3dChoice[]>> = {
* dino_v3_vit_h) and TRELLIS.2 (a DINOv3 ViT-L encoder, dino_v3_L_naf in Comfy-Org's repackage) do; Hunyuan3D,
* Tripo, Meshy and SAM 3D don't. Open models get theirs from their workflow's licence.
*/
-export const CLOUD_NOTICES: Record<string, string[]> = { triposplat: ["Built with DINOv3"], "trellis-2": ["Built with DINOv3"] };
+export const CLOUD_NOTICES: Record<string, string[]> = { triposplat: ["Built with DINOv3"], "idol-3d": ["Built with DINOv3"], "trellis-2": ["Built with DINOv3"] };
+
+/** Idol 3D on each engine: the open graph (image-to-splat-idol) and fal's speridlabs/idol. */
+export const IDOL_MODELS = { open: "oss-idol", cloud: "idol-3d" } as const;
+export const isIdol = (id: string | null | undefined) => id === IDOL_MODELS.open || id === IDOL_MODELS.cloud;
+
+export type IdolQuality = "best" | "quick";
+
+/**
+ * Idol 3D's two settings on the open engine (the graph's bindings, sent as params.extra). best is Idol's reference
+ * (idol-sdk: 50 Euler steps, CFG weight 3 in its (1+w) form = ComfyUI cfg 4, 262,144 Gaussians); quick is the
+ * ComfyUI-Idol README's "faster trade-off" (20 dpmpp_2m steps) and "fast preview" (65,536 Gaussians), quality
+ * unmeasured (docs/research/idol-9.md §11). Labelled by steps and Gaussians, never by seconds.
+ */
+export const IDOL_PRESETS: Record<IdolQuality, { steps: number; sampler: string; cfg: number; numGaussians: number }> = {
+ best: { steps: 50, sampler: "euler", cfg: 4, numGaussians: 262144 },
+ quick: { steps: 20, sampler: "dpmpp_2m", cfg: 4, numGaussians: 65536 },
+};
+
+/** The two settings as the page offers them. */
+export const IDOL_QUALITIES: { id: IdolQuality; label: string; hint: string }[] = [
+ { id: "best", label: "Best", hint: "50 steps · 262,144 Gaussians" },
+ { id: "quick", label: "Quick look", hint: "20 steps · 65,536 Gaussians" },
+];
+
+/**
+ * Idol 3D's settings for a request: on the open engine the graph's (photoCrop picks the looser crop), on fal the
+ * endpoint's own fields. fal takes the steps, the Gaussians and the kind of picture ("real" is Idol's photo crop),
+ * but no sampler and no CFG in ComfyUI's form, so its guidance stays fal's default (Idol's reference weight 3).
+ */
+export function idolExtra(engine: Engine, quality: IdolQuality = "best", photoCrop = false): Record<string, unknown> {
+ const p = IDOL_PRESETS[quality] ?? IDOL_PRESETS.best;
+ if (engine === "open") return { ...p, photoCrop };
+ return { num_inference_steps: p.steps, num_gaussians: p.numGaussians, image_type: photoCrop ? "real" : "synthetic" };
+}
/** Every model the page offers (⌘K's ?model= links land on its mode). */
export const ALL_MODELS_3D: Model3dChoice[] = Object.values(MODELS_3D).flatMap((m) => [...m.cloud, ...m.open]);
@@ -100,6 +141,10 @@ export interface Model3dInput {
views?: Partial<Record<ViewSide, string>>;
/** From text: the object; Pick an object: what to take out. */
prompt?: string;
+ /** Splat with Idol 3D: Best (its reference settings, the default) or Quick look. */
+ quality?: IdolQuality;
+ /** Splat with Idol 3D: the picture is a photo, so the object gets Idol's looser crop. */
+ photoCrop?: boolean;
}
/** The model for a mode and engine: the one picked when the mode offers it, else its default (null: none on that engine). */
@@ -152,7 +197,8 @@ export function model3dRequest(i: Model3dInput): GenerationRequest {
case "objects":
return { ...base, op: "image-to-3d", prompt, inputs: { images } };
case "splat":
- return { ...base, op: "splat", inputs: { images } };
+ // Idol 3D gets its Best / Quick look settings and the photo crop; TripoSplat's request is unchanged.
+ return { ...base, op: "splat", inputs: { images }, ...(isIdol(modelId) && { params: { extra: idolExtra(i.engine, i.quality, !!i.photoCrop) } }) };
default:
return { ...base, op: "image-to-3d", inputs: { images } };
}
diff --git a/src/server/assist/tools.ts b/src/server/assist/tools.ts
index 89e2153d..49e1475b 100644
--- a/src/server/assist/tools.ts
+++ b/src/server/assist/tools.ts
@@ -96,7 +96,7 @@ const searchModels = defineTool({
.string()
.optional()
.describe(
- "Operation id to filter by, e.g. t2i, edit, t2v, i2v, flf2v, ref2v, extend, lipsync, avatar, tts, upscale-image, layers, text-layers, trim, transcribe, captions, mux, separate-audio, translate, write, image-to-3d.",
+ "Operation id to filter by, e.g. t2i, edit, t2v, i2v, flf2v, ref2v, extend, lipsync, avatar, tts, upscale-image, layers, text-layers, trim, transcribe, captions, mux, separate-audio, translate, write, image-to-3d, splat.",
),
query: z.string().optional().describe("Words to match in the model name, vendor or description, e.g. 'kling', 'cheap', 'photoreal'."),
}),
@@ -257,7 +257,7 @@ const Job = z.object({
.string()
.optional()
.describe(
- "Operation id (t2i, edit, t2v, i2v, flf2v, ref2v, extend, tts, layers, transcribe, translate, write, trim, captions, mux, separate-audio, image-to-3d…). Usually inferred from the inputs; set it when ambiguous.",
+ "Operation id (t2i, edit, t2v, i2v, flf2v, ref2v, extend, tts, layers, transcribe, translate, write, trim, captions, mux, separate-audio, image-to-3d, splat…). Usually inferred from the inputs; set it when ambiguous.",
),
images: z.array(ref).optional().describe("Input images: the image to edit, the start frame, or references, in order."),
end_image: ref.optional().describe("End frame (first-and-last-frame video)."),
diff --git a/tests/account-idol.test.ts b/tests/account-idol.test.ts
new file mode 100644
index 00000000..e2d8a2a1
--- /dev/null
+++ b/tests/account-idol.test.ts
@@ -0,0 +1,83 @@
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { afterAll, beforeAll, describe, expect, it } from "vitest";
+import { startFakeComfy, TINY_PNG, type FakeComfy } from "./helpers/fake-comfy-runner";
+
+/**
+ * Idol 3D (idol-1) under public sign-up: 3D models are closed to accounts, so an account's Idol run answers 403
+ * own-gpu-tool on both engines — on its own linked ComfyUI (oss-idol) and with its own fal.ai key (idol-3d) — and
+ * nothing reaches its GPU or fal.
+ */
+
+const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-account-idol-"));
+process.env.FUOBE_DATA_DIR = dir;
+process.env.COMFYUI_URL = "http://owner-comfy.test:8188";
+process.env.FUOBE_PUBLIC_SIGNUP = "1";
+delete process.env.FUOBE_PASSWORD;
+delete process.env.FUOBE_ENGINE_MODE;
+globalThis.__fuobeTestDiskFree = 1e13;
+
+const realFetch = globalThis.fetch;
+const fetched: string[] = [];
+globalThis.fetch = (async (u: RequestInfo | URL) => {
+ fetched.push(String(u));
+ return new Response("not stubbed", { status: 599 });
+}) as typeof fetch;
+
+const auth = await import("@/server/auth");
+const keys = await import("@/server/account-keys");
+const generationsRoute = await import("@/app/api/generations/route");
+const { saveFile } = await import("@/server/storage");
+const { getModel } = await import("@/lib/catalog");
+const { model3dRequest } = await import("@/lib/av/model3d");
+
+let fake: FakeComfy;
+let cookie = "";
+let account = "";
+beforeAll(async () => {
+ fake = await startFakeComfy({ loras: [], delayMs: 0 });
+ globalThis.__fuobeTestGpuPort = fake.port;
+ auth.setPassword("install password");
+ account = auth.createAccount("[email protected]", "long enough").id;
+ auth.setAccountGpu(account, { url: fake.url });
+ keys.saveAccountKey(account, "fal", "acct-fal-idol");
+ cookie = `${auth.SESSION_COOKIE}=${auth.createSession(account).value}`;
+});
+afterAll(async () => {
+ globalThis.fetch = realFetch;
+ globalThis.__fuobeTestGpuPort = undefined;
+ globalThis.__fuobeTestDiskFree = undefined;
+ await fake.close();
+ fs.rmSync(dir, { recursive: true, force: true });
+});
+
+const post = (body: unknown) => {
+ const text = JSON.stringify(body);
+ return generationsRoute.POST(
+ new Request("http://localhost:3000/api/generations", {
+ method: "POST",
+ headers: { cookie, host: "localhost:3000", "content-type": "application/json", "content-length": String(Buffer.byteLength(text)) },
+ body: text,
+ }) as never,
+ );
+};
+
+describe("Idol 3D stays closed to accounts", () => {
+ it.each([
+ ["open", "oss-idol"],
+ ["cloud", "idol-3d"],
+ ] as const)("on the %s engine (%s): 403 own-gpu-tool, nothing sent", async (engine, modelId) => {
+ expect(getModel(modelId)?.engine).toBe(engine);
+ const photo = saveFile({ data: TINY_PNG, contentType: "image/png", source: "upload", accountId: account }).url;
+ const req = model3dRequest({ engine, mode: "splat", modelId, photo, quality: "quick", photoCrop: true });
+ expect(req.modelId).toBe(modelId);
+ fake.log.length = 0;
+ fetched.length = 0;
+ const r = await post(req);
+ expect(r.status, await r.clone().text()).toBe(403);
+ expect((await r.json()).code).toBe("own-gpu-tool");
+ expect(fake.log.filter((e) => e.path === "/prompt" || e.path === "/upload/image")).toHaveLength(0);
+ expect(fetched.filter((u) => /fal\.(run|ai|media)/.test(u))).toHaveLength(0);
+ });
+});