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.

Originals O3: Photodump and moodboards on Fuobe Soul with trained LoRAs

Claude0f43a8f8c719
diff --git a/src/app/api/moodboards/[id]/train/route.ts b/src/app/api/moodboards/[id]/train/route.ts
index a4d069e6..12e4da7e 100644
--- a/src/app/api/moodboards/[id]/train/route.ts
+++ b/src/app/api/moodboards/[id]/train/route.ts
@@ -1,10 +1,21 @@
-import { trainMoodboard } from "@/server/moodboards";
+import { connection } from "next/server";
+import { z } from "zod";
+import { moodboardTrainingTargets, trainMoodboard } from "@/server/moodboards";
-/** Train the board as a Z-Image Turbo style LoRA (a style element, AI-Toolkit on your own GPU). */
-export async function POST(_req: Request, ctx: RouteContext<"/api/moodboards/[id]/train">) {
+/** The style trainings a board can run (each with its price, what stops it and whether it would be a demo). */
+export async function GET() {
+ await connection();
+ return Response.json({ targets: moodboardTrainingTargets() });
+}
+
+const Body = z.object({ target: z.string().min(1).optional() }).nullable();
+
+/** Train the board as a Fuobe look: a Z-Image Turbo style LoRA on your GPU (AI-Toolkit) or in the cloud (fal). */
+export async function POST(request: Request, ctx: RouteContext<"/api/moodboards/[id]/train">) {
const { id } = await ctx.params;
+ const parsed = Body.safeParse(await request.json().catch(() => null));
try {
- return Response.json(trainMoodboard(id), { status: 202 });
+ return Response.json(trainMoodboard(id, parsed.success ? parsed.data?.target : undefined), { status: 202 });
} catch (e) {
return Response.json({ error: (e as Error).message }, { status: /not found/i.test((e as Error).message) ? 404 : 409 });
}
diff --git a/src/components/fashion/character-sheet.tsx b/src/components/fashion/character-sheet.tsx
index 0d522567..3795d7a6 100644
--- a/src/components/fashion/character-sheet.tsx
+++ b/src/components/fashion/character-sheet.tsx
@@ -137,7 +137,7 @@ export function SaveCharacter({ item, extra, defaultName }: { item: Generation;
</Button>
<p className="w-full text-[12px] text-muted-foreground">
Use it anywhere with <AtSign className="inline size-3" />
- mentions, in <Link href="/photodump" className="text-brand-text underline underline-offset-2">Photodump</Link> or <Link href="/fashion-factory" className="text-brand-text underline underline-offset-2">Fashion Factory</Link> — or train a Soul ID / LoRA from its page.
+ mentions, in <Link href="/photodump" className="text-brand-text underline underline-offset-2">Photodump</Link> or <Link href="/fashion-factory" className="text-brand-text underline underline-offset-2">Fashion Factory</Link> — or train its Soul ID from its page.
</p>
</div>
);
diff --git a/src/components/moodboards/logic.ts b/src/components/moodboards/logic.ts
index 92c957dc..edccc6c0 100644
--- a/src/components/moodboards/logic.ts
+++ b/src/components/moodboards/logic.ts
@@ -24,8 +24,8 @@ export interface Moodboard {
styleId: string | null;
error: string | null;
generationId: string | null;
- /** The style element trained from this board (Z-Image Turbo LoRA). */
- lora: { elementId: string; handle: string; status: "none" | "training" | "ready" | "failed" } | null;
+ /** The style element trained from this board (a Z-Image Turbo LoRA, its Fuobe look); "demo" = a demo training's stand-in. */
+ lora: { elementId: string; handle: string; status: "none" | "training" | "ready" | "failed" | "demo" } | null;
createdAt: number;
}
diff --git a/src/components/photodump/photodump-view.tsx b/src/components/photodump/photodump-view.tsx
index 1a28c497..5d11e453 100644
--- a/src/components/photodump/photodump-view.tsx
+++ b/src/components/photodump/photodump-view.tsx
@@ -12,7 +12,7 @@ import { EngineSwitch } from "@/components/studio/engine-switch";
import { fileToList, type SlotValue } from "@/components/studio/media-slot";
import { radioKeys, radioTab } from "@/components/studio/radio-keys";
import { useElements, useEngine, useGenerations } from "@/lib/api";
-import { customPack, DEFAULT_ASPECT, MAX_PACK_REFS, MAX_SELFIE_MB, PACKS, PHOTODUMP_ASPECTS, PHOTODUMP_MODELS, type Pack } from "@/lib/catalog/packs";
+import { customPack, DEFAULT_ASPECT, MAX_PACK_REFS, MAX_SELFIE_MB, PACKS, PHOTODUMP_ASPECTS, PHOTODUMP_MODELS, PHOTODUMP_SOUL, soulIdOf, type Pack } from "@/lib/catalog/packs";
import type { Generation } from "@/lib/catalog/types";
import { timeAgo } from "@/lib/format";
import { cn } from "@/lib/utils";
@@ -25,10 +25,9 @@ import { UploadBox } from "./upload-box";
const STEPS = ["Choose a Pack", "Add your photo", "Get your photos"];
const MODEL_NAMES: Record<string, string> = {
- "soul-2": "Soul 2.0",
+ "fuobe-soul": "Fuobe Soul + Soul ID",
"nano-banana-pro": "Nano Banana Pro",
"seedream-5-pro": "Seedream 5.0 Pro",
- "oss-z-image-turbo": "Z-Image Turbo + LoRA",
"oss-qwen-edit": "Qwen-Image-Edit",
};
const TABS = [
@@ -181,10 +180,10 @@ export function PhotodumpView() {
const character = subjectMode === "character" ? elements.data?.find((e) => e.id === elementId) : undefined;
const choices: (string | undefined)[] = [undefined, ...PHOTODUMP_MODELS[engine]];
const unavailable = (m?: string): string | null => {
- if (m !== "oss-z-image-turbo") return null;
- if (pack?.custom) return "Your own packs recreate each reference photo with Qwen-Image-Edit";
- if (!character) return "Needs a character with a trained LoRA";
- return character.loras.some((l) => l.modelId === "oss-z-image-turbo" && l.engine === "open" && !l.referenceId) ? null : `${character.name} has no trained LoRA yet`;
+ if (m !== PHOTODUMP_SOUL) return null;
+ if (pack?.custom) return "Your own packs recreate each reference photo with an edit model";
+ if (!character) return "Needs a character with a trained Soul ID";
+ return soulIdOf({ kind: "element", handle: character.handle, name: character.name, references: character.references, loras: character.loras }, engine) ? null : `${character.name} has no Soul ID yet`;
};
const pick = choices.includes(modelPick) && !unavailable(modelPick) ? modelPick : undefined;
const body = pack && subjectReady
@@ -332,7 +331,7 @@ export function PhotodumpView() {
) : (
<div className="space-y-2">
<CharacterPicker value={elementId} onChange={setElementId} />
- <p className="text-[12px] text-muted-foreground">Characters with a trained Soul ID (cloud) or LoRA (open source) keep the face best; others are sent as reference photos.</p>
+ <p className="text-[12px] text-muted-foreground">Characters with a trained Soul ID keep the face best (Fuobe Soul, on either engine); others are sent as reference photos.</p>
</div>
)}
</div>
diff --git a/src/components/photodump/subject.tsx b/src/components/photodump/subject.tsx
index 5c203171..4e9ac0d4 100644
--- a/src/components/photodump/subject.tsx
+++ b/src/components/photodump/subject.tsx
@@ -11,25 +11,23 @@ import { Skeleton } from "@/components/ui/skeleton";
import { fileToList, type SlotValue } from "@/components/studio/media-slot";
import { useElements, useSaveElement } from "@/lib/api";
import type { StudioElement } from "@/lib/catalog/elements";
+import { SOUL_ID_COPY, SOUL_ID_PHOTOS } from "@/lib/catalog/training";
import { cn } from "@/lib/utils";
-/** What a character brings: a trained Soul ID, a trained LoRA, or just photos. */
+/** What a character brings: a trained Soul ID (Fuobe Soul), an old Higgsfield one to retrain, or just photos. */
export function identityLabel(el: StudioElement): string {
- if (el.loras.some((l) => l.referenceId)) return "Soul ID";
- if (el.loras.length) return "LoRA";
+ if (el.loras.some((l) => !l.referenceId && !l.demo)) return "Soul ID";
+ if (el.loras.some((l) => l.referenceId)) return "Retrain Soul ID";
return `${el.references.length} photo${el.references.length === 1 ? "" : "s"}`;
}
-/** Higgsfield's character-creation copy (docs/research/higgsfield-image-studios.md §2). */
+/** The character-creation copy (src/lib/catalog/training.ts SOUL_ID_COPY, Higgsfield's rules): saving is the consent. */
const CREATE_COPY = {
- more: "Upload 20+ photos for best results",
- moreTitle: "More Photos, Better Results",
- avoidTitle: "Avoid These Types of Photos",
- avoid: "No duplicates, group shots, pets, nudes, filters, face-covering accessories, or masks",
- consent: "By clicking Save character, I consent to this biometric data processing and confirm these photos are of me or of a person at least 18 years old who gave written permission.",
+ ...SOUL_ID_COPY,
+ consent: `By clicking Save character, ${SOUL_ID_COPY.consent.charAt(0).toLowerCase()}${SOUL_ID_COPY.consent.slice(1)}`,
} as const;
-const MAX_PHOTOS = 20;
+const MAX_PHOTOS = SOUL_ID_PHOTOS.max;
/** Create a character from photos of one person, without leaving the page. */
export function QuickCharacter({ open, onOpenChange, onCreated }: { open: boolean; onOpenChange: (o: boolean) => void; onCreated: (el: StudioElement) => void }) {
diff --git a/src/lib/catalog/packs.ts b/src/lib/catalog/packs.ts
index c1e16309..bf20b038 100644
--- a/src/lib/catalog/packs.ts
+++ b/src/lib/catalog/packs.ts
@@ -14,6 +14,7 @@
*/
import type { ElementLora } from "./elements";
import { styleWords } from "./palettes";
+import { identityFor } from "./training";
import { FASHION_TEMPLATES, PHOTODUMP_PACKS, SOUL_CATEGORIES, SOUL_PRESETS, type FashionTemplateMeta, type PackMeta, type SoulPreset, type SoulPresetModel } from "./higgsfield-presets.generated";
import type { Engine, GenerationRequest } from "./types";
@@ -407,48 +408,43 @@ export type PhotoSubject =
/** What the server knows about this install, for planning. */
export interface PlanCaps {
- /** A Higgsfield key is set (Soul 2.0 with a Soul ID can run for real). */
+ /** A Higgsfield key is set (the Character Sheet's Soul 2.0 builder can run for real until build plan O7). */
higgsfield: boolean;
/** Models this install has (open-source workflows can be missing). */
has?: (id: string) => boolean;
}
+/** Fuobe Soul: a character with a trained Soul ID makes its photos there, on either engine (build plan O3). */
+export const PHOTODUMP_SOUL = "fuobe-soul";
+
export const PHOTODUMP_MODELS: Record<Engine, string[]> = {
- cloud: ["soul-2", "nano-banana-pro", "seedream-5-pro"],
- open: ["oss-z-image-turbo", "oss-qwen-edit"],
+ cloud: [PHOTODUMP_SOUL, "nano-banana-pro", "seedream-5-pro"],
+ open: [PHOTODUMP_SOUL, "oss-qwen-edit"],
};
-const soulId = (s: PhotoSubject) => (s.kind === "element" ? s.loras.find((l) => l.modelId === "soul-2" && l.referenceId) : undefined);
-const turboLora = (s: PhotoSubject) => (s.kind === "element" ? s.loras.find((l) => l.modelId === "oss-z-image-turbo" && l.engine === "open" && !l.referenceId) : undefined);
+/** The character's Soul ID that runs on Fuobe Soul on this engine (a demo training's stand-in doesn't count). */
+export const soulIdOf = (s: PhotoSubject, engine: Engine): ElementLora | undefined => (s.kind === "element" ? identityFor(s.loras, { id: PHOTODUMP_SOUL, engine }) : undefined);
/**
- * Which model makes a subject's photos: a trained identity where there is one (Soul 2.0 + Soul ID,
- * Z-Image Turbo + the character LoRA), otherwise a multi-reference edit model with their photos.
- * `pick` is the user's choice among PHOTODUMP_MODELS, honoured when it can work.
+ * Which model makes a subject's photos: Fuobe Soul with the character's trained Soul ID (its LoRA) where there is
+ * one, on either engine; otherwise a multi-reference edit model with their photos. `pick` is the user's choice among
+ * PHOTODUMP_MODELS, honoured when it can work.
*/
-export function photodumpModel(subject: PhotoSubject, engine: Engine, caps: PlanCaps, pick?: string, custom = false): { modelId: string; note?: string } {
- if (engine === "open") {
- if (!custom && turboLora(subject) && pick !== "oss-qwen-edit") return { modelId: "oss-z-image-turbo" };
- // Say why when the pick (or a character without a LoRA) ends up on Qwen-Image-Edit.
- const note =
- pick === "oss-z-image-turbo" && custom
- ? "Your own packs recreate each reference photo — Qwen-Image-Edit runs them"
- : pick === "oss-z-image-turbo" && subject.kind === "selfie"
- ? "Z-Image Turbo + LoRA needs a character with a trained LoRA — Qwen-Image-Edit works from your photo"
- : subject.kind === "element" && !turboLora(subject) && !custom
- ? "No trained LoRA yet — Qwen-Image-Edit works from the character's photos"
- : undefined;
- return { modelId: "oss-qwen-edit", note };
- }
- if (!custom && soulId(subject) && caps.higgsfield && (!pick || pick === "soul-2")) return { modelId: "soul-2" };
- const m = pick === "seedream-5-pro" ? "seedream-5-pro" : "nano-banana-pro";
+export function photodumpModel(subject: PhotoSubject, engine: Engine, _caps: PlanCaps, pick?: string, custom = false): { modelId: string; note?: string } {
+ const trained = soulIdOf(subject, engine);
+ if (!custom && trained && (!pick || pick === PHOTODUMP_SOUL)) return { modelId: PHOTODUMP_SOUL };
+ // Say why when the pick (or a character without a Soul ID) ends up on an edit model.
+ const fallback = engine === "open" ? "oss-qwen-edit" : pick === "seedream-5-pro" ? "seedream-5-pro" : "nano-banana-pro";
+ const name = fallback === "oss-qwen-edit" ? "Qwen-Image-Edit" : fallback === "seedream-5-pro" ? "Seedream 5.0 Pro" : "Nano Banana Pro";
const note =
- pick === "soul-2"
- ? soulId(subject)
- ? "Soul 2.0 needs a Higgsfield key — using Nano Banana Pro with the photos"
- : "Soul 2.0 needs a trained Soul ID — using Nano Banana Pro with the photos"
- : undefined;
- return { modelId: m, note };
+ pick === PHOTODUMP_SOUL && custom
+ ? `Your own packs recreate each reference photo — ${name} runs them`
+ : pick === PHOTODUMP_SOUL && subject.kind === "selfie"
+ ? `Fuobe Soul needs a character with a trained Soul ID — ${name} works from your photo`
+ : pick === PHOTODUMP_SOUL || (engine === "open" && subject.kind === "element" && !trained && !custom)
+ ? `No Soul ID yet — ${name} works from the character's photos (train them for Fuobe Soul on the Elements page)`
+ : undefined;
+ return { modelId: fallback, note };
}
const KEEP_FACE = "Keep their exact face, identity, skin tone and hair; a new photo, not a copy of the reference";
@@ -480,7 +476,7 @@ export interface PhotodumpPlan {
/**
* One request per photo of the pack, in order ("Photo 3 of 15"), each making one image. Saved
- * characters are @mentioned (the server turns that into a Soul ID, a LoRA or reference photos);
+ * characters are @mentioned (the server turns that into their trained Soul ID LoRA or reference photos);
* a selfie goes in as image 1. User packs add their reference photo after the subject.
*/
export function planPhotodump(input: PhotodumpInput, caps: PlanCaps): PhotodumpPlan {
@@ -501,6 +497,8 @@ export function planPhotodump(input: PhotodumpInput, caps: PlanCaps): PhotodumpP
return {
feature: "photodump",
modelId: route.modelId,
+ // Fuobe Soul runs on both engines: the run's engine picks its half.
+ engine: input.engine,
prompt: shotPrompt(pack, shot, subject, refIndex),
inputs: images.length ? { images } : undefined,
params: { numOutputs: 1, ...(aspect && { aspectRatio: aspect }) },
@@ -645,6 +643,7 @@ export function fashionBaseRequest(t: FashionTemplate, subject: Extract<PhotoSub
return {
feature: "fashion",
modelId,
+ engine,
prompt: `A full-body fashion photo of ${element(subject)} in ${t.look}. A natural, relaxed model pose looking at the camera, simple fitted basics so the outfit can be changed later, photorealistic, sharp detail.`,
params: { aspectRatio: "3:4", numOutputs: 4 },
step: { label: "Base shots", index: 0, of: 3 },
diff --git a/src/lib/catalog/palettes.ts b/src/lib/catalog/palettes.ts
index 5ea00f56..6ce046b4 100644
--- a/src/lib/catalog/palettes.ts
+++ b/src/lib/catalog/palettes.ts
@@ -23,7 +23,8 @@
* `request.prompt`: they ride in `request.signature.words`, which the server adds when it plans the
* run, so feeds, Library titles and Reuse keep the user's own words.
*/
-import { DEFAULT_LOOK, lookCard, SOUL_MODEL_IDS } from "./soul-cards";
+import { DEFAULT_LOOK, lookCard, OWN_LOOK, SOUL_MODEL_IDS } from "./soul-cards";
+import { familyOfModel } from "./training";
import type { GenerationRequest, GenParams, ModelDef, Operation } from "./types";
export type RGB = [number, number, number];
@@ -397,6 +398,8 @@ export const SIGNATURE_MODELS = {
openStyle: "oss-style-qwen-edit",
openPalette: "oss-zimage-palette",
openTurbo: "oss-z-image-turbo",
+ /** A personal moodboard trained as a style LoRA runs here, the LoRA as its look (both engines). */
+ soul: SOUL_MODEL_IDS.soul,
paletteLock: "oss-palette-image",
soul2: "soul-2",
soul1: "soul-1",
@@ -523,8 +526,20 @@ export function applySignature(req: GenerationRequest, sig: Signature | undefine
const collages = mb.collages?.length ? mb.collages : refs.slice(0, 2);
// A request that already carries the board's images (Run again of an older run): nothing to add.
const carried = [...refs, ...collages].some((u) => r.inputs?.images?.includes(u));
+ // A board trained as a style LoRA is a Fuobe look (build plan O3): on Fuobe Soul (and plain Z-Image Turbo, whose
+ // family the LoRA is) on either engine, and on the open engine instead of collages for any model but a
+ // style-reference one. A partner model in the cloud keeps the board's images as style references.
+ const zFamily = familyOfModel(model.id) === "z-image-turbo";
+ const asLook = !!mb.loraHandle && (zFamily || (model.engine === "open" && model.family !== "style-reference"));
if (carried) {
// Leave the request as it is.
+ } else if (asLook) {
+ // Soul Cinema's film look is fixed: the board's look runs on Fuobe Soul, on the engine the run was on.
+ const engine = r.engine ?? model.engine;
+ if (!zFamily || model.id === SOUL_MODEL_IDS.cinema) move(SIGNATURE_MODELS.soul, `Runs on {model} with the trained “${mb.name}” style as its look`);
+ r = { ...r, engine };
+ if (model.options.looks) r = { ...r, presetId: OWN_LOOK };
+ words.push(`In the style of @${mb.loraHandle}.`);
} else if (model.engine === "cloud") {
if (model.family === "recraft" && mb.styleId) {
move(SIGNATURE_MODELS.recraftSaved, `Runs on {model} with the saved “${mb.name}” Recraft style`);
@@ -547,9 +562,6 @@ export function applySignature(req: GenerationRequest, sig: Signature | undefine
r = { ...r, op: "edit", inputs: { ...r.inputs, images: [...(r.inputs?.images ?? []), ...take] } };
words.push(styleLegend(existing + 1, existing + take.length));
}
- } else if (mb.loraHandle && (model.id === SIGNATURE_MODELS.openTurbo || model.family !== "style-reference")) {
- move(SIGNATURE_MODELS.openTurbo, `Runs on {model} with the trained “${mb.name}” style LoRA`);
- words.push(`In the style of @${mb.loraHandle}.`);
} else {
if (model.family !== "style-reference") move(SIGNATURE_MODELS.openStyle, `Runs on {model} with the “${mb.name}” collages`);
const max = model.options.maxImages ?? 2;
diff --git a/src/lib/catalog/soul-cards.ts b/src/lib/catalog/soul-cards.ts
index 7d545e9d..7b624e75 100644
--- a/src/lib/catalog/soul-cards.ts
+++ b/src/lib/catalog/soul-cards.ts
@@ -30,6 +30,12 @@ export const SOUL_MODEL_IDS = { soul: "fuobe-soul", hd: "fuobe-soul-hd", cinema:
/** The look a Fuobe Soul run uses when none is picked: Soul's own default. */
export const DEFAULT_LOOK = "v1-general";
+/**
+ * A personal moodboard trained as a style LoRA (build plan O3) is the look: its LoRA comes in as the user's own (the
+ * moodboard's style element, @mentioned), with no look words, LoRAs, tail or grade of Soul's around it.
+ */
+export const OWN_LOOK = "own-style";
+
const BY_ID = new Map(SOUL_LOOK_CARDS.map((c) => [c.id, c]));
/** A look's card by its Fuobe id, or by Higgsfield's old style id (settings saved before the Originals). */
diff --git a/src/lib/catalog/soul.ts b/src/lib/catalog/soul.ts
index ea62d58f..56fc8e1f 100644
--- a/src/lib/catalog/soul.ts
+++ b/src/lib/catalog/soul.ts
@@ -18,7 +18,7 @@
* (`legacyStyleId`); they are never sent anywhere.
*/
import { loraEntry, loraRef } from "./loras";
-import { DEFAULT_LOOK, SOUL_MODEL_IDS } from "./soul-cards";
+import { DEFAULT_LOOK, OWN_LOOK, SOUL_MODEL_IDS } from "./soul-cards";
import { SOUL_CINEMA, SOUL_CORE_LORAS, SOUL_ORIGINALS, SOUL_SIZES, SOUL_TAILS } from "./soul-originals.generated";
import type { LoraRef, ModelDef } from "./types";
@@ -67,7 +67,7 @@ export interface SoulCinemaRecipe {
/** The Soul Originals' model ids. */
export const SOUL_MODELS = SOUL_MODEL_IDS;
export type SoulModelId = (typeof SOUL_MODELS)[keyof typeof SOUL_MODELS];
-export { DEFAULT_LOOK };
+export { DEFAULT_LOOK, OWN_LOOK };
/** Which Soul a model is (none for other models). */
export function soulKind(model: Pick<ModelDef, "id"> | string | undefined): "soul" | "hd" | "cinema" | undefined {
@@ -192,7 +192,11 @@ export function soulRecipe(
let sentence = "";
let grade: string | undefined;
let overlay: SoulOverlay | undefined;
- if (kind === "cinema") {
+ if (kind !== "cinema" && opts.look === OWN_LOOK) {
+ // The trained moodboard's LoRA (among the user's own) carries the look.
+ picked = [];
+ tail = "art";
+ } else if (kind === "cinema") {
if (opts.look) notes.push("Soul Cinema has one film look, so the look you picked isn't used");
picked = SOUL_CINEMA.loras;
tail = SOUL_CINEMA.tail;
diff --git a/src/server/moodboards.ts b/src/server/moodboards.ts
index e1837e4f..4aa58219 100644
--- a/src/server/moodboards.ts
+++ b/src/server/moodboards.ts
@@ -1,13 +1,14 @@
import "server-only";
import { nanoid } from "nanoid";
-import { getTrainingTarget } from "@/lib/catalog/training";
+import { getTrainingTarget, identityFor, targetsFor, type TrainingTarget } from "@/lib/catalog/training";
+import { MAX_ELEMENT_PHOTOS } from "@/lib/catalog/elements";
import type { Engine, Generation } from "@/lib/catalog/types";
import { COVER_PROMPT, CURATED_SETS, MOODBOARD_LIMITS, moodboardStatus, moodboardError, type CuratedMoodboard, type Moodboard } from "@/components/moodboards/logic";
import { db } from "./db";
import { createElement, getElement } from "./elements";
import { createGenerations, getGeneration } from "./generations";
import { engineMode } from "./settings";
-import { startTraining, trainingBlocker } from "./training";
+import { demoTraining, describeTargets, startTraining, trainingBlocker } from "./training";
/**
* Moodboards (Soul 2.0's "presets evolved"): a named set of 5–80 reference images in one style.
@@ -16,8 +17,9 @@ import { startTraining, trainingBlocker } from "./training";
* Styles turns the 10 most representative images into a reusable style (its id comes back in
* meta.styleId) while drawing the cover; on the open engine Qwen-Image-Edit Style Reference draws
* the cover from the board's collages. The status follows that job: In queue → In progress →
- * Preparing cover → Complete (or Failed, with Retry). A board can also train a Z-Image Turbo style
- * LoRA through the existing AI-Toolkit path (a style element), which then wins on the open engine.
+ * Preparing cover → Complete (or Failed, with Retry). A board can also be trained as a Z-Image Turbo style LoRA
+ * (Fuobe Soul ID's style trainings, build plan O3: AI-Toolkit on the user's GPU or fal's Z-Image trainer in style
+ * mode): a style element whose LoRA is then the board's Fuobe look, on Fuobe Soul on either engine.
*/
interface Row {
@@ -42,7 +44,9 @@ export const PREP_MODEL: Record<Engine, string> = { cloud: "recraft-4-style", op
function toMoodboard(r: Row): Moodboard {
const images = JSON.parse(r.images_json) as string[];
const el = r.element_id ? getElement(r.element_id) : null;
- const lora = el?.loras.find((l) => l.modelId === "oss-z-image-turbo" && l.engine === "open");
+ // The style LoRA that runs on Fuobe Soul on some engine (a demo training's stand-in says so instead).
+ const lora = el && (identityFor(el.loras, { id: STYLE_MODEL, engine: "open" }) ?? identityFor(el.loras, { id: STYLE_MODEL, engine: "cloud" }));
+ const demo = !lora && el?.loras.some((l) => l.demo);
return {
id: r.id,
name: r.name,
@@ -55,7 +59,9 @@ function toMoodboard(r: Row): Moodboard {
styleId: r.style_id,
error: r.error,
generationId: r.generation_id,
- lora: el ? { elementId: el.id, handle: el.handle, status: lora ? "ready" : el.status === "training" ? "training" : el.status === "failed" ? "failed" : "none" } : null,
+ lora: el
+ ? { elementId: el.id, handle: el.handle, status: el.status === "training" ? "training" : lora ? "ready" : demo ? "demo" : el.status === "failed" ? "failed" : "none" }
+ : null,
createdAt: r.created_at,
};
}
@@ -183,27 +189,40 @@ export function deleteMoodboard(id: string): boolean {
return db().prepare("DELETE FROM moodboards WHERE id = ?").run(id).changes > 0;
}
-/** A board's persistent open-source style: a Z-Image Turbo LoRA trained on AI-Toolkit. */
-const STYLE_TARGET = "aitk-z-image";
+/** The model a trained board's look runs on. */
+const STYLE_MODEL = "fuobe-soul";
+
+/** The style trainings a board can run on (AI-Toolkit on the user's GPU, fal in the cloud), with what stops each. */
+export function moodboardTrainingTargets() {
+ return describeTargets(targetsFor("style"));
+}
+
+/** The style training a board runs when none is named: the engine mode's, else the board's own engine. */
+function defaultStyleTarget(m: Moodboard): TrainingTarget {
+ const mode = engineMode();
+ const engine = mode === "both" ? m.engine : mode;
+ return targetsFor("style").find((t) => t.engine === engine) ?? targetsFor("style")[0];
+}
/**
- * Train a persistent open-source style: a style element with the board's 20 most representative
- * images, trained as a Z-Image Turbo LoRA on AI-Toolkit (the same path as character LoRAs).
+ * Train a board as a Fuobe look: a style element with the board's most representative images (up to 80), trained as
+ * a Z-Image Turbo style LoRA on the target asked (AI-Toolkit on the user's GPU, or fal's Z-Image trainer in style
+ * mode). The LoRA then runs on Fuobe Soul on both engines as the board's look.
*/
-export function trainMoodboard(id: string): Moodboard {
+export function trainMoodboard(id: string, targetId?: string): Moodboard {
const m = getMoodboard(id);
if (!m) throw new Error("Moodboard not found");
- if (engineMode() === "cloud") throw new Error("This install is set to paid cloud APIs only (Settings → Engine mode) — a style LoRA trains on your own GPU");
if (m.status !== "complete") throw new Error("This moodboard is still training. Try again once it is ready.");
- // Say what's missing (an AI-Toolkit URL) before making the style element, so a refusal leaves nothing behind.
- const target = getTrainingTarget(STYLE_TARGET);
- const blocker = target && trainingBlocker(target);
- if (blocker) throw new Error(blocker);
+ const target = targetId ? getTrainingTarget(targetId) : defaultStyleTarget(m);
+ if (!target || !target.kinds.includes("style")) throw new Error("Pick a style training");
+ // Say what's missing (a key, an AI-Toolkit URL, the engine mode) before making the style element, so a refusal leaves nothing behind.
+ const blocker = trainingBlocker(target);
+ if (blocker && !demoTraining(target)) throw new Error(blocker);
let el = m.lora ? getElement(m.lora.elementId) : null;
if (!el) {
- el = createElement({ name: m.name.slice(0, 60), kind: "style", description: `the visual style of the “${m.name}” moodboard`, references: m.images.slice(0, 20) });
+ el = createElement({ name: m.name.slice(0, 60), kind: "style", description: `the visual style of the “${m.name}” moodboard`, references: m.images.slice(0, MAX_ELEMENT_PHOTOS) });
update(id, { element_id: el.id });
}
- startTraining(el.id, STYLE_TARGET);
+ startTraining(el.id, target.id);
return getMoodboard(id)!;
}
diff --git a/tests/image-studios-api.test.ts b/tests/image-studios-api.test.ts
index b77c0645..1c045879 100644
--- a/tests/image-studios-api.test.ts
+++ b/tests/image-studios-api.test.ts
@@ -1,7 +1,10 @@
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
-import { afterAll, beforeAll, describe, expect, it } from "vitest";
+import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
+
+// A route's GET opts out of prerendering with connection(), which needs a request scope.
+vi.mock("next/server", async (importOriginal) => ({ ...(await importOriginal<typeof import("next/server")>()), connection: async () => {} }));
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-image-studios-"));
process.env.FUOBE_DATA_DIR = dir;
@@ -160,9 +163,16 @@ describe("moodboards", () => {
expect(list.items.map((x) => x.id)).toContain(m.id);
expect(list.curated).toHaveLength(33);
expect(new Set(list.curated.map((c) => c.category))).toEqual(new Set(["All presets", "Mood", "Styles", "Camera"]));
- // A style LoRA needs AI-Toolkit: without its URL the board says where to set it up and makes no element.
- expect(() => moodboards.trainMoodboard(m.id)).toThrow(/AI-Toolkit URL/);
+ // A style LoRA on the GPU needs AI-Toolkit: with demo mode off and no URL, the board says where to set it up and makes no element.
+ setSetting("demoMode", "off");
+ try {
+ expect(() => moodboards.trainMoodboard(m.id, "aitk-z-image")).toThrow(/AI-Toolkit URL/);
+ } finally {
+ setSetting("demoMode", "auto");
+ }
expect(moodboards.getMoodboard(m.id)!.lora).toBeNull();
+ // In demo mode it runs a demo training: the board shows it, and nothing real is attached.
+ expect(moodboards.trainMoodboard(m.id, "aitk-z-image").lora?.status).toBe("training");
}, 45_000);
it("prepares cloud boards on Recraft V4 Styles with the 10 most representative images", () => {
@@ -212,12 +222,12 @@ describe("moodboards", () => {
}
});
- it("a style LoRA trains with the style preset, and is refused on a cloud-only install", async () => {
+ it("a style LoRA trains with the style preset, on the GPU or in the cloud as the engine mode allows", async () => {
const job = aiToolkitJob({ name: "x", trigger: "nnhzfz", datasetFolder: "/d", outputFolder: "/o", kind: "style" });
const train = job.config.process[0];
expect(train.train.steps).toBe(1500);
expect(train.sample.prompts.every((p: string) => p.endsWith("nnhzfz style"))).toBe(true);
- expect(aiToolkitJob({ name: "x", trigger: "t", datasetFolder: "/d", outputFolder: "/o" }).config.process[0].train.steps).toBe(2500);
+ expect(aiToolkitJob({ name: "x", trigger: "t", datasetFolder: "/d", outputFolder: "/o" }).config.process[0].train.steps).toBe(2000);
expect(trainingCaption("style", "nnhzfz", "the visual style of the “Neon Haze” moodboard.")).toBe("nnhzfz style, the visual style of the “Neon Haze” moodboard");
expect(trainingCaption("character", "mayafz")).toBe("photo of mayafz");
@@ -226,10 +236,21 @@ describe("moodboards", () => {
setSetting("demoMode", "auto");
setSetting("engineMode", "cloud");
try {
- const res = await trainRoute.POST(json("POST"), params({ id: m.id }) as never);
+ // The GPU is ruled out on a cloud-only install, even as a demo; the cloud style trainer is what's offered.
+ const res = await trainRoute.POST(json("POST", { target: "aitk-z-image" }), params({ id: m.id }) as never);
expect(res.status).toBe(409);
expect((await res.json()).error).toMatch(/cloud APIs only/);
expect(moodboards.getMoodboard(m.id)!.lora).toBeNull();
+ const targets = (await (await trainRoute.GET()).json()).targets as { id: string; price: string; blocker: string | null; demo: boolean }[];
+ expect(targets.map((t) => [t.id, t.price])).toEqual([
+ ["aitk-z-image", "Free"],
+ ["fal-z-image-style", "≈ $3.39 (1,500 steps)"],
+ ]);
+ expect(targets[0].blocker).toMatch(/cloud APIs only/);
+ // No target named: the engine mode's (the cloud), here a demo (no fal key).
+ const started = await trainRoute.POST(json("POST"), params({ id: m.id }) as never);
+ expect(started.status).toBe(202);
+ expect((await started.json()).lora.status).toBe("training");
} finally {
setSetting("engineMode", "both");
moodboards.deleteMoodboard(m.id);
@@ -279,9 +300,9 @@ describe("photodump, fashion factory and character sheet runs", () => {
expect(preview.notes.join()).toMatch(/keeps the shape of your photo/);
const cloud = await (await photodumpRoute.POST(json("POST", { packId: "winter-special", engine: "cloud", selfie: upload(), aspectRatio: "16:9" }, "http://x/api/photodump?preview=1"))).json();
expect(cloud.fixedAspect).toBe(false);
- // Picking Z-Image Turbo + LoRA with a selfie says why it runs on Qwen-Image-Edit.
- const z = await (await photodumpRoute.POST(json("POST", { packId: "zen", engine: "open", selfie: upload(), modelId: "oss-z-image-turbo" }, "http://x/api/photodump?preview=1"))).json();
- expect(z.notes[0]).toMatch(/needs a character with a trained LoRA/);
+ // Picking Fuobe Soul with a selfie says why it runs on Qwen-Image-Edit.
+ const z = await (await photodumpRoute.POST(json("POST", { packId: "zen", engine: "open", selfie: upload(), modelId: "fuobe-soul" }, "http://x/api/photodump?preview=1"))).json();
+ expect(z.notes[0]).toMatch(/needs a character with a trained Soul ID/);
});
it("makes a user pack and a character's photodump on the open engine", async () => {
diff --git a/tests/image-studios.test.ts b/tests/image-studios.test.ts
index 34437638..5d1deedb 100644
--- a/tests/image-studios.test.ts
+++ b/tests/image-studios.test.ts
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
import { getModel, getPreset } from "@/lib/catalog";
import { castName, randomizeCast, SOUL_CAST_FIELDS } from "@/lib/catalog/cinema";
import { applyMentions, type StudioElement } from "@/lib/catalog/elements";
+import { onEngine } from "@/lib/catalog/engines";
import { PHOTODUMP_PACKS, SOUL_DEFAULT, SOUL_PRESETS } from "@/lib/catalog/higgsfield-presets.generated";
import {
castFieldVisible,
@@ -484,15 +485,26 @@ describe("Photodump packs and planning", () => {
expect(cloud.requests[2].step).toEqual({ label: "Photo 3 of 9", index: 2, of: 9 });
expect(cloud.requests.every((r) => r.params?.numOutputs === 1 && r.params.aspectRatio === "3:4" && r.feature === "photodump")).toBe(true);
- const soulMaya: PhotoSubject = { ...maya, loras: [{ engine: "cloud", modelId: "soul-2", file: "", trigger: "", referenceId: "ref-123" }] };
- expect(planPhotodump({ pack, subject: soulMaya, engine: "cloud" }, { higgsfield: true }).modelId).toBe("soul-2");
- const noKey = planPhotodump({ pack, subject: soulMaya, engine: "cloud", modelId: "soul-2" }, { higgsfield: false });
- expect(noKey.modelId).toBe("nano-banana-pro");
- expect(noKey.notes[0]).toMatch(/Higgsfield key/);
+ // A trained Soul ID (build plan O3): Fuobe Soul with the character's LoRA on either engine; Higgsfield's is gone.
+ const soulMaya: PhotoSubject = { ...maya, loras: [{ engine: "cloud", modelId: "fuobe-soul", family: "z-image-turbo", file: "fuobe/maya-a1.safetensors", url: "https://v3.fal.media/maya.safetensors", own: true, trigger: "mayfz" }] };
+ for (const engine of ["cloud", "open"] as const) {
+ const run = planPhotodump({ pack, subject: soulMaya, engine }, { higgsfield: true });
+ expect(run.modelId).toBe("fuobe-soul");
+ expect(run.requests.every((r) => r.engine === engine)).toBe(true);
+ }
+ const oldSoulId: PhotoSubject = { ...maya, loras: [{ engine: "cloud", modelId: "soul-2", file: "", trigger: "", referenceId: "ref-123" }] };
+ expect(planPhotodump({ pack, subject: oldSoulId, engine: "cloud" }, { higgsfield: true }).modelId).toBe("nano-banana-pro");
+ const untrained = planPhotodump({ pack, subject: maya, engine: "cloud", modelId: "fuobe-soul" }, { higgsfield: false });
+ expect(untrained.modelId).toBe("nano-banana-pro");
+ expect(untrained.notes[0]).toMatch(/No Soul ID yet/);
+ expect(planPhotodump({ pack, subject: soulMaya, engine: "cloud", modelId: "seedream-5-pro" }, { higgsfield: false }).modelId).toBe("seedream-5-pro");
expect(planPhotodump({ pack, subject: maya, engine: "cloud", modelId: "seedream-5-pro" }, { higgsfield: false }).modelId).toBe("seedream-5-pro");
+ // A LoRA trained before O3 for plain Z-Image Turbo is the same family: it runs on Fuobe Soul too.
const loraMaya: PhotoSubject = { ...maya, loras: [{ engine: "open", modelId: "oss-z-image-turbo", file: "maya.safetensors", trigger: "mayfz" }] };
- expect(planPhotodump({ pack, subject: loraMaya, engine: "open" }, { higgsfield: false }).modelId).toBe("oss-z-image-turbo");
+ expect(planPhotodump({ pack, subject: loraMaya, engine: "open" }, { higgsfield: false }).modelId).toBe("fuobe-soul");
+ // A GPU-only LoRA (no copy Fuobe can send) stays off the cloud: reference photos there.
+ expect(planPhotodump({ pack, subject: loraMaya, engine: "cloud" }, { higgsfield: false }).modelId).toBe("nano-banana-pro");
const qwen = planPhotodump({ pack, subject: selfie, engine: "open", aspectRatio: "auto" }, { higgsfield: false });
expect(qwen.modelId).toBe("oss-qwen-edit");
expect(qwen.requests[0].inputs?.images).toEqual([selfie.url]);
@@ -518,23 +530,33 @@ describe("Photodump packs and planning", () => {
const refs = check(maya, "cloud", el([]));
expect(refs.plan.op).toBe("edit");
expect(refs.resolved.inputs?.images).toEqual(["/api/files/uploads/m1.png"]);
- const soulLoras = [{ engine: "cloud" as const, modelId: "soul-2", file: "", trigger: "", referenceId: "ref-1" }];
- const soul = check({ ...maya, loras: soulLoras }, "cloud", el(soulLoras));
- expect(soul.resolved.params?.extra?.custom_reference_id).toBe("ref-1");
- expect(soul.plan.model.id).toBe("soul-2");
- const turbo = [{ engine: "open" as const, modelId: "oss-z-image-turbo", file: "maya.safetensors", trigger: "mayfz" }];
- const lora = check({ ...maya, loras: turbo }, "open", el(turbo));
- expect(lora.plan.loras[0].file).toBe("maya.safetensors");
- expect(lora.plan.prompt).toMatch(/mayfz Maya/);
+ // The Soul ID's LoRA on Fuobe Soul, first in its slots, on the engine the run asked for.
+ const trained = [{ engine: "cloud" as const, modelId: "fuobe-soul", family: "z-image-turbo" as const, file: "fuobe/maya-a1.safetensors", url: "https://v3.fal.media/maya.safetensors", own: true as const, trigger: "mayfz" }];
+ for (const engine of ["cloud", "open"] as const) {
+ const p = planPhotodump({ pack: getPack("zen")!, subject: { ...maya, loras: trained }, engine, aspectRatio: "3:4" }, { higgsfield: false });
+ const r = p.requests[0];
+ const model = onEngine(getModel(r.modelId)!, r.engine!);
+ const resolved = applyMentions(r, model, [el(trained)]).request;
+ const planned = planGeneration(resolved, (id) => (id === model.id ? model : getModel(id)), getPreset);
+ expect(planned.model).toMatchObject({ id: "fuobe-soul", engine });
+ expect(planned.loras[0]).toMatchObject({ file: "fuobe/maya-a1.safetensors", own: true });
+ expect(planned.prompt).toMatch(/mayfz Maya/);
+ expect(resolved.inputs?.images).toBeUndefined();
+ }
});
});
describe("Photodump: model choice and retries", () => {
const selfie: PhotoSubject = { kind: "selfie", url: "/api/files/uploads/me.png" };
+
it("says why a pick that can't run ends up on another model", () => {
- expect(photodumpModel(selfie, "open", { higgsfield: false }, "oss-z-image-turbo")).toEqual({ modelId: "oss-qwen-edit", note: "Z-Image Turbo + LoRA needs a character with a trained LoRA — Qwen-Image-Edit works from your photo" });
- expect(photodumpModel(selfie, "open", { higgsfield: false }, "oss-z-image-turbo", true).note).toMatch(/Your own packs recreate each reference photo/);
+ expect(photodumpModel(selfie, "open", { higgsfield: false }, "fuobe-soul")).toEqual({ modelId: "oss-qwen-edit", note: "Fuobe Soul needs a character with a trained Soul ID — Qwen-Image-Edit works from your photo" });
+ expect(photodumpModel(selfie, "cloud", { higgsfield: false }, "fuobe-soul").note).toMatch(/Nano Banana Pro works from your photo/);
+ expect(photodumpModel(selfie, "open", { higgsfield: false }, "fuobe-soul", true).note).toMatch(/Your own packs recreate each reference photo/);
expect(photodumpModel(selfie, "open", { higgsfield: false }).note).toBeUndefined();
+ // A demo training's stand-in isn't a Soul ID.
+ const demo: PhotoSubject = { kind: "element", handle: "Maya", name: "Maya", references: ["/a.png"], loras: [{ engine: "cloud", modelId: "fuobe-soul", family: "z-image-turbo", file: "fuobe/x.safetensors", trigger: "t", demo: true }] };
+ expect(photodumpModel(demo, "open", { higgsfield: false }).modelId).toBe("oss-qwen-edit");
});
it("a retried base shot or outfit takes the failed one's place in the wizard", () => {
diff --git a/tests/soul-fixes.test.ts b/tests/soul-fixes.test.ts
index 4f87063f..626c6ff5 100644
--- a/tests/soul-fixes.test.ts
+++ b/tests/soul-fixes.test.ts
@@ -21,7 +21,7 @@ const { onEngine } = await import("@/lib/catalog/engines");
const { estimateCost, planGeneration } = await import("@/lib/catalog/plan");
const { applySignature } = await import("@/lib/catalog/palettes");
const { loraEntry, loraRef } = await import("@/lib/catalog/loras");
-const { soulPostSteps } = await import("@/lib/catalog/soul");
+const { OWN_LOOK, soulPostSteps } = await import("@/lib/catalog/soul");
const { cropRect, finishSteps } = await import("@/lib/soul-post");
const { findModels } = await import("@/lib/model-list");
const { toModelRow } = await import("@/lib/model-rows");
@@ -80,10 +80,16 @@ describe("a look beside a moodboard that moves the run", () => {
expect(signed.notes.join(" ")).toMatch(/Y2K look is Fuobe Soul's own/);
expect(() => planGeneration(signed.request, view(engine), getPreset)).not.toThrow();
}
- // A trained style moves an open run to Z-Image Turbo: the same.
- const trained = applySignature({ feature: "image", modelId: "fuobe-soul", prompt: "a lighthouse", presetId: "v1-y2k", engine: "open" }, { moodboard: { ...board, loraHandle: "dusk" } }, { caps: { native: {} }, getModel: view("open") });
- expect(trained.modelId).toBe("oss-z-image-turbo");
- expect(trained.request.presetId).toBeUndefined();
+ // A trained style is a Fuobe look (build plan O3): it stays on Fuobe Soul on either engine, the LoRA as the look.
+ for (const engine of ["cloud", "open"] as const) {
+ const trained = applySignature({ feature: "image", modelId: "fuobe-soul", prompt: "a lighthouse", presetId: "v1-y2k", engine }, { moodboard: { ...board, loraHandle: "dusk" } }, { caps: { native: {} }, getModel: view(engine) });
+ expect(trained.modelId).toBe("fuobe-soul");
+ expect(trained.request).toMatchObject({ presetId: OWN_LOOK, engine, signature: { words: "In the style of @dusk." } });
+ expect(() => planGeneration(trained.request, view(engine), getPreset)).not.toThrow();
+ }
+ // Soul Cinema's look is fixed: the board's look moves the run to Fuobe Soul.
+ const cine = applySignature({ feature: "image", modelId: "fuobe-soul-cinema", prompt: "a lighthouse", engine: "cloud" }, { moodboard: { ...board, loraHandle: "dusk" } }, { caps: { native: {} }, getModel: view("cloud") });
+ expect(cine).toMatchObject({ modelId: "fuobe-soul", request: { presetId: OWN_LOOK, engine: "cloud" } });
// A curated look stays a look on Fuobe Soul.
const curated = applySignature({ feature: "image", modelId: "fuobe-soul", prompt: "a lighthouse", engine: "cloud" }, { moodboard: { id: "v2-y2k-studio", kind: "curated", name: "Y2K Studio", status: "complete" } }, { caps: { native: {} }, getModel: view("cloud") });
expect(curated.request.presetId).toBe("v2-y2k-studio");
diff --git a/tests/training.test.ts b/tests/training.test.ts
index e3e99cd8..375f8af7 100644
--- a/tests/training.test.ts
+++ b/tests/training.test.ts
@@ -27,6 +27,7 @@ import {
usableOn,
} from "@/lib/catalog/training";
import { buildPayload } from "@/lib/catalog/payload";
+import { OWN_LOOK, soulPostSteps, soulRecipe } from "@/lib/catalog/soul";
import { zip } from "@/server/zip";
const ROOT = path.resolve(__dirname, "..");
@@ -214,6 +215,15 @@ describe("a Soul ID on every model of its family, on both engines", () => {
expect(plan.prompt).toMatch(/myfz Maya on a beach/);
});
+ it("makes a trained moodboard the look on Fuobe Soul: its LoRA alone, no look words, tail or grade", () => {
+ const style = { file: "fuobe/dusk-a1.safetensors", strength: 1, trigger: "dskfz", own: true as const };
+ const r = soulRecipe("soul", "dskfz Dusk, a lighthouse at night", { look: OWN_LOOK, userLoras: [style] });
+ expect(r.loras).toEqual([style]);
+ expect(r.prompt).toBe("dskfz Dusk, a lighthouse at night.");
+ expect(r.grade).toBeUndefined();
+ expect(soulPostSteps("fuobe-soul", OWN_LOOK)).toBeUndefined();
+ });
+
it("falls back to reference photos when no LoRA runs there", () => {
const el = maya([lora({ engine: "open" })]);
const nb = getModel("nano-banana-pro")!;