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: Idol 3D keeps Best or Quick look per engine, and an earlier upload from the library counts as a photo

Claudebca88d416e31
diff --git a/src/components/model3d/model3d-studio.tsx b/src/components/model3d/model3d-studio.tsx
index 8ef8cec8..edc1ee97 100644
--- a/src/components/model3d/model3d-studio.tsx
+++ b/src/components/model3d/model3d-studio.tsx
@@ -27,6 +27,7 @@ import {
SIDE_LABELS,
SIDES_HINT,
VIEW_SIDES,
+ idolPhotoFor,
isIdol,
model3dBlocker,
model3dFor,
@@ -199,9 +200,10 @@ 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");
+ // Idol 3D (Splat): Best or Quick look, kept per mode and engine like the model pick, and whether the picture is a
+ // photo, which belongs to the picture (shared by every mode). A picture uploaded or dropped here, or an earlier upload
+ // picked from the library, is taken for a photo; a result made here for a render or a generated image.
+ const [idolQualities, setIdolQualities] = useState<Record<string, IdolQuality>>({});
const [idolPhoto, setIdolPhoto] = useState(true);
// The last value the drop gave (an upload reports twice: uploading, then done, from one closure).
const lastPhoto = useRef<SlotValue | null>(null);
@@ -209,10 +211,8 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
const prev = lastPhoto.current;
lastPhoto.current = v;
setPhoto(v);
- if (v && v.ref !== prev?.ref) {
- if (v.uploading) setIdolPhoto(true);
- else if (!prev?.uploading) setIdolPhoto(false);
- }
+ const asPhoto = idolPhotoFor(v, prev);
+ if (asPhoto !== undefined) setIdolPhoto(asPhoto);
};
const [views, setViews] = useState<Partial<Record<ViewSide, SlotValue | null>>>({});
const [text, setText] = useState("");
@@ -234,6 +234,8 @@ export function Model3dStudio({ info }: { info: Record<string, Model3dInfo> }) {
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 idol = mode === "splat" && isIdol(modelId);
+ const idolQuality = idolQualities[`${mode}:${engine}`] ?? "best";
+ const setIdolQuality = (q: IdolQuality) => setIdolQualities((p) => ({ ...p, [`${mode}:${engine}`]: q }));
const input: Model3dInput = {
engine,
mode,
diff --git a/src/components/studio/media-slot.tsx b/src/components/studio/media-slot.tsx
index 64158c96..aa556048 100644
--- a/src/components/studio/media-slot.tsx
+++ b/src/components/studio/media-slot.tsx
@@ -25,6 +25,8 @@ export interface SlotValue {
kind: MediaKind;
name?: string;
uploading?: boolean;
+ /** Picked from the library: whether it was an upload or a result made here. */
+ source?: "upload" | "generation";
/** Drawings and masks: the strokes they were made from, so the editor reopens them (in image pixels). */
sketch?: { mode: SketchMode; strokes: Stroke[] };
}
@@ -174,7 +176,7 @@ export function LibraryGrid({ kinds, onPick }: { kinds: MediaKind[]; onPick: (v:
key={a.id}
className="aspect-square overflow-hidden rounded-md bg-muted ring-primary transition outline-none hover:ring-2 focus-visible:ring-2"
aria-label={a.name ?? `${a.kind} from your library`}
- onClick={() => onPick({ ref: a.url, preview: a.url, kind: a.kind, name: a.name ?? undefined })}
+ onClick={() => onPick({ ref: a.url, preview: a.url, kind: a.kind, name: a.name ?? undefined, source: a.source })}
>
<SlotPreview value={{ preview: a.url, kind: a.kind }} />
</button>
diff --git a/src/lib/av/model3d.ts b/src/lib/av/model3d.ts
index a9f08112..f49c242f 100644
--- a/src/lib/av/model3d.ts
+++ b/src/lib/av/model3d.ts
@@ -109,6 +109,21 @@ export function idolExtra(engine: Engine, quality: IdolQuality = "best", photoCr
return { num_inference_steps: p.steps, num_gaussians: p.numGaussians, image_type: photoCrop ? "real" : "synthetic" };
}
+/**
+ * Whether a new picture reads as a photo for Idol's crop: an upload (dropped here, or an earlier one picked from the
+ * library) is; a result made here (a render or a generated image) isn't. undefined: the picture is the same one, or the
+ * second report of an upload already counted, so the switch keeps what the person set.
+ */
+export function idolPhotoFor(
+ next: { ref: string; uploading?: boolean; source?: "upload" | "generation" } | null,
+ prev: { ref: string; uploading?: boolean } | null | undefined,
+): boolean | undefined {
+ if (!next || next.ref === prev?.ref) return undefined;
+ if (next.uploading) return true;
+ if (prev?.uploading) return undefined;
+ return next.source === "upload";
+}
+
/** 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]);
diff --git a/tests/model3d.test.ts b/tests/model3d.test.ts
index 33bbfce7..c4bc2ac6 100644
--- a/tests/model3d.test.ts
+++ b/tests/model3d.test.ts
@@ -340,6 +340,20 @@ 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("takes an upload for a photo and a result made here for a render; a repeat or an upload's second report keeps the switch", () => {
+ // Dropped or uploaded here: on, as soon as it starts uploading.
+ expect(m3d.idolPhotoFor({ ref: "", uploading: true }, null)).toBe(true);
+ // The same upload's second report (done) keeps what the person may have set meanwhile.
+ expect(m3d.idolPhotoFor({ ref: "/api/files/a.png" }, { ref: "", uploading: true })).toBeUndefined();
+ // From the library: an earlier upload is a photo; a result made here is not.
+ expect(m3d.idolPhotoFor({ ref: "/api/files/up.jpg", source: "upload" }, { ref: "/api/files/a.png" })).toBe(true);
+ expect(m3d.idolPhotoFor({ ref: "/api/files/gen.png", source: "generation" }, null)).toBe(false);
+ expect(m3d.idolPhotoFor({ ref: "/api/files/x.png" }, null)).toBe(false);
+ // The same picture again, or a cleared slot: unchanged.
+ expect(m3d.idolPhotoFor({ ref: "/api/files/a.png", source: "upload" }, { ref: "/api/files/a.png" })).toBeUndefined();
+ expect(m3d.idolPhotoFor(null, { ref: "/api/files/a.png" })).toBeUndefined();
+ });
+
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" })]);