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: train a moodboard as a look on either engine, priced first

Claude1630cd503afd
diff --git a/src/components/moodboards/hooks.ts b/src/components/moodboards/hooks.ts
index 02a383fd..17d6450b 100644
--- a/src/components/moodboards/hooks.ts
+++ b/src/components/moodboards/hooks.ts
@@ -40,7 +40,8 @@ export function useMoodboardActions() {
});
const retry = useMutation({ mutationFn: (b: { id: string; engine?: Engine }) => post<Moodboard>(`/api/moodboards/${b.id}/retry`, { engine: b.engine }), onSuccess: done });
const train = useMutation({
- mutationFn: (id: string) => post<Moodboard>(`/api/moodboards/${id}/train`),
+ // target: a style training from GET /api/moodboards/<id>/train (your GPU or the cloud); none = the engine's own.
+ mutationFn: (b: { id: string; target?: string }) => post<Moodboard>(`/api/moodboards/${b.id}/train`, b.target ? { target: b.target } : undefined),
onSuccess: () => {
done();
void qc.invalidateQueries({ queryKey: ["elements"] });
diff --git a/src/components/moodboards/moodboards-view.tsx b/src/components/moodboards/moodboards-view.tsx
index 8edefaee..9473dc80 100644
--- a/src/components/moodboards/moodboards-view.tsx
+++ b/src/components/moodboards/moodboards-view.tsx
@@ -26,6 +26,7 @@ import { useEngine } from "@/lib/api";
import { cn } from "@/lib/utils";
import { BoardCover, CuratedCover, StatusBadge } from "./cards";
import { CreateMoodboardDialog } from "./create-moodboard";
+import { TrainBoardDialog } from "./train-board";
import { useCuratedSet, useMoodboardActions, useMoodboards } from "./hooks";
import { COPY, CURATED_TABS, inCuratedTab, MOODBOARD_LIMITS, type Moodboard } from "./logic";
@@ -50,9 +51,9 @@ function CreateFromUrl({ onOpen }: { onOpen: () => void }) {
}
function BoardCard({ m, onRename, onDelete }: { m: Moodboard; onRename: () => void; onDelete: () => void }) {
- const { retry, train } = useMoodboardActions();
- const router = useRouter();
- // Settings can lock one engine: then there's no other engine to rebuild for, and no open-source LoRA on cloud only.
+ const { retry } = useMoodboardActions();
+ const [training, setTraining] = useState(false);
+ // Settings can lock one engine: then there's no other engine to rebuild for.
const [, , mode] = useEngine();
const ready = m.status === "complete";
return (
@@ -104,25 +105,16 @@ function BoardCard({ m, onRename, onDelete }: { m: Moodboard; onRename: () => vo
<RotateCcw /> {m.status === "failed" ? "Retry" : `Rebuild for ${m.engine === "cloud" ? "open source" : "cloud"}`}
</DropdownMenuItem>
)}
- {mode !== "cloud" && (
- <DropdownMenuItem
- disabled={!ready || m.lora?.status === "training"}
- onSelect={() =>
- train.mutate(m.id, {
- onSuccess: () => toast.success("Training a style LoRA on your GPU"),
- onError: (e) => toast.error((e as Error).message, { action: /Settings/.test((e as Error).message) ? { label: "Settings", onClick: () => router.push("/settings#training") } : undefined }),
- })
- }
- >
- <GraduationCap /> {m.lora?.status === "ready" ? "Retrain style LoRA" : "Train a style LoRA"}
- </DropdownMenuItem>
- )}
+ <DropdownMenuItem disabled={!ready || m.lora?.status === "training"} onSelect={() => setTimeout(() => setTraining(true))}>
+ <GraduationCap /> {m.lora?.status === "ready" ? "Retrain as a look…" : "Train as a look…"}
+ </DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem variant="destructive" onSelect={() => setTimeout(onDelete)}>
<Trash2 /> Delete
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
+ <TrainBoardDialog board={m} open={training} onOpenChange={setTraining} />
</div>
<div className="mt-2 flex items-baseline justify-between gap-2 px-0.5">
<p className="min-w-0 truncate text-[13.5px] font-medium">{m.name}</p>
diff --git a/src/components/moodboards/train-board.tsx b/src/components/moodboards/train-board.tsx
new file mode 100644
index 00000000..1dbf8755
--- /dev/null
+++ b/src/components/moodboards/train-board.tsx
@@ -0,0 +1,95 @@
+"use client";
+
+import { useQuery } from "@tanstack/react-query";
+import { Cloud, Cpu, GraduationCap, Loader2 } from "lucide-react";
+import Link from "next/link";
+import { toast } from "sonner";
+import { Button } from "@/components/ui/button";
+import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";
+import { licenceNote, type TrainingTarget } from "@/lib/catalog/training";
+import { cn } from "@/lib/utils";
+import { useMoodboardActions } from "./hooks";
+import type { Moodboard } from "./logic";
+
+type Target = TrainingTarget & { blocker: string | null; demo: boolean };
+
+/**
+ * Train a board as a Fuobe look (a style LoRA on Fuobe Soul's base): on your GPU (AI-Toolkit, free) or in the cloud
+ * (fal's Z-Image trainer in style mode), each with its price first. The LoRA then is the look on Fuobe Soul on both engines.
+ */
+export function TrainBoardDialog({ board, open, onOpenChange }: { board: Moodboard; open: boolean; onOpenChange: (o: boolean) => void }) {
+ const { train } = useMoodboardActions();
+ const q = useQuery({
+ queryKey: ["moodboard-train", board.id],
+ queryFn: async () => (await (await fetch(`/api/moodboards/${board.id}/train`)).json()) as { targets: Target[] },
+ enabled: open,
+ });
+ const targets = q.data?.targets ?? [];
+ const retrain = board.lora?.status === "ready";
+ return (
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogContent className="max-h-[90svh] overflow-y-auto sm:max-w-[520px]">
+ <DialogHeader>
+ <DialogTitle className="flex items-center gap-2">
+ <GraduationCap className="size-5" /> {retrain ? "Retrain" : "Train"} “{board.name}” as a look
+ </DialogTitle>
+ <DialogDescription>
+ Its {Math.min(board.images.length, 80)} images become a style LoRA. On Fuobe Soul the LoRA is the whole look, on your GPU and in the cloud, instead of
+ reference images.
+ </DialogDescription>
+ </DialogHeader>
+ <div className="space-y-2">
+ {q.isLoading && <p className="text-[13px] text-muted-foreground">Loading training options…</p>}
+ {targets.map((t) => (
+ <div key={t.id} className="rounded-xl border p-3">
+ <div className="flex flex-wrap items-start gap-3">
+ <span className="mt-0.5 grid size-8 shrink-0 place-items-center rounded-lg bg-muted text-muted-foreground">
+ {t.engine === "open" ? <Cpu className="size-4" /> : <Cloud className="size-4" />}
+ </span>
+ <div className="min-w-0 flex-1 basis-44">
+ <p className="flex flex-wrap items-center gap-x-2 text-[14px] font-medium">
+ {t.name}
+ <span className={cn("rounded-full px-2 py-px text-[11.5px] font-medium tabular-nums", t.costUsd === 0 ? "bg-success/15 text-success" : "bg-muted text-foreground")}>
+ {t.costUsd === 0 ? "Free" : `$${t.costUsd.toFixed(2)}`}
+ </span>
+ <span className="text-[12px] font-normal text-muted-foreground">{t.eta}</span>
+ </p>
+ <p className="text-[12px] text-muted-foreground">{t.description}</p>
+ <p className="mt-0.5 text-[11.5px] text-muted-foreground">Licence: {licenceNote(t)}</p>
+ </div>
+ <Button
+ size="sm"
+ className="ml-auto"
+ disabled={!!t.blocker || train.isPending || board.lora?.status === "training"}
+ onClick={() =>
+ train.mutate(
+ { id: board.id, target: t.id },
+ {
+ onSuccess: () => {
+ toast.success(t.demo ? "Demo training: nothing real is trained" : `Training “${board.name}” as a look — you can keep working`);
+ onOpenChange(false);
+ },
+ onError: (e) => toast.error((e as Error).message),
+ },
+ )
+ }
+ >
+ {train.isPending && train.variables?.target === t.id && <Loader2 className="animate-spin" />}
+ {retrain ? "Retrain" : "Train"}
+ </Button>
+ </div>
+ {(t.blocker || t.demo) && (
+ <p className="mt-2 text-[12px] text-muted-foreground">
+ {t.blocker ?? (t.provider === "fal" ? "No fal.ai key yet: this runs as a demo and trains nothing." : "No AI-Toolkit set up yet: this runs as a demo and trains nothing.")}{" "}
+ <Link href="/settings#training" className="text-brand-text underline underline-offset-2">
+ Open Settings
+ </Link>
+ </p>
+ )}
+ </div>
+ ))}
+ </div>
+ </DialogContent>
+ </Dialog>
+ );
+}