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.

Merge branch 'r4/marketing-mixed' into claude/fuobe-parity-4

Claude697d8abdf589
diff --cc src/server/generations.ts
index d5dce108,57dd1b73..a5c124dc
--- a/src/server/generations.ts
+++ b/src/server/generations.ts
@@@ -10,10 -10,10 +10,11 @@@ import { cueText, type Cue } from "@/li
import { HELPER_FEATURES, HELPER_SUFFIX, isReviewStatus, type AssetUse, type ReviewFilter } from "@/lib/library";
import { upscaleTier } from "@/lib/av/upscale";
import { chainedWaitMessage, keyframeChain } from "@/lib/catalog/keyframes";
-import { estimateCost, inferOperation, planGeneration, routesFor } from "@/lib/catalog/plan";
-import { keepMatte } from "@/lib/catalog/payload";
+import { estimateCost, inferOperation, planGeneration, routeLoras, routesFor } from "@/lib/catalog/plan";
+import { framedLength, keepMatte } from "@/lib/catalog/payload";
+import { fitLoras, lorasFit } from "@/lib/catalog/loras";
import {
+ CHAIN_LIST_SLACK,
LAST_FRAME_CHAIN,
OPERATION_OUTPUT,
type ChainSlot,
diff --cc src/server/mixed-media.ts
index 87c55048,bc9e643a..2a86ccb9
--- a/src/server/mixed-media.ts
+++ b/src/server/mixed-media.ts
@@@ -17,10 -22,10 +22,10 @@@ import
} from "@/lib/catalog/mixed-media";
import { clipLengthProblem, type PlanStep } from "@/lib/catalog/shorts";
import { sourceSeconds, takesImage } from "@/lib/catalog/shorts-models";
-import type { Engine, Generation } from "@/lib/catalog/types";
+import type { Engine, Generation, ProviderId } from "@/lib/catalog/types";
import { createPipeline } from "./chains";
import { db } from "./db";
- import { getGeneration, previewChained } from "./generations";
+ import { DROPPED_UNUSED, getGeneration, previewChained, unfilledRequest, waitedOnFailure } from "./generations";
import { engineMode } from "./settings";
import { probeSource, ShortsError } from "./shorts";
@@@ -104,41 -153,49 +153,63 @@@ async function planInput(body: MixedBod
const withChain = (s: PlanStep) => ({ ...s.request, ...(s.chain ? { chain: s.chain } : {}) });
+ /** Every step validated and priced; steps alike but for their place in the chain (a frame each) are previewed once. */
-function price(steps: PlanStep[]): { costUsd: number | null; demo: boolean } {
+function price(steps: PlanStep[]): { costUsd: number | null; demo: boolean; providers: ProviderId[] } {
let cost: number | null = 0;
let demo = false;
+ const providers = new Set<ProviderId>();
+ const seen = new Map<string, ReturnType<typeof previewChained>>();
for (const s of steps) {
- const p = previewChained(withChain(s), s.after?.length ?? 0);
+ const req = withChain(s);
+ const key = JSON.stringify([req.modelId, req.op, req.prompt, req.inputs, req.params, req.chain?.map((c) => c.slot), s.after?.length ?? 0]);
+ const p = seen.get(key) ?? previewChained(req, s.after?.length ?? 0);
+ seen.set(key, p);
demo ||= p.demo;
+ providers.add(p.providerId);
cost = cost === null || p.costUsd === null ? null : cost + p.costUsd;
}
- return { costUsd: cost === null ? null : Math.round(cost * 10000) / 10000, demo };
+ return { costUsd: cost === null ? null : Math.round(cost * 10000) / 10000, demo, providers: [...providers] };
}
export interface MixedEstimate {
costUsd: number | null;
previewUsd: number | null;
demo: boolean;
+ /** The model that restyles the clip, and where the steps run ("mock" for demo steps), for the evaluation harness. */
+ modelId: string;
+ providers: ProviderId[];
frames: number;
+ /** The frame rate the frames are taken at (cloud Per frame: the clip's own over a whole number). */
fps: number;
+ /** Cloud: how it restyles. */
+ mode?: MixedMode;
+ /** Cloud Per frame: the price of redrawing one frame (Higgsfield's 2 credits a frame). */
+ perFrameUsd?: number | null;
notes: string[];
}
export async function estimateMixed(body: MixedBody): Promise<MixedEstimate> {
- const { input, frames, notes } = await planInput(body, { probe: false });
- const full = price(planMixed(input).steps);
+ const { input, frames, fps, notes } = await planInput(body, { probe: false });
+ const plan = planMixed(input);
+ const full = price(plan.steps);
const preview = price([planMixedPreview({ ...input, frameUrl: body.frameUrl ?? "/api/files/placeholder.png" })]);
- return { ...full, previewUsd: preview.costUsd, modelId: input.modelId, frames, fps: input.fps, notes };
+ const frame = input.mode === "frames" ? plan.steps.find((s) => s.key === "f0") : undefined;
+ const perFrameUsd = frame ? previewChained(withChain(frame), frame.after?.length ?? 0).costUsd : undefined;
- return { ...full, previewUsd: preview.costUsd, frames, fps, notes, ...(input.mode && { mode: input.mode }), ...(perFrameUsd !== undefined && { perFrameUsd }) };
++ return {
++ ...full,
++ previewUsd: preview.costUsd,
++ modelId: input.modelId,
++ frames,
++ fps,
++ notes,
++ ...(input.mode && { mode: input.mode }),
++ ...(perFrameUsd !== undefined && { perFrameUsd }),
++ };
}
- function run(steps: PlanStep[]): { batchId: string; items: Generation[]; byKey: Record<string, Generation> } {
+ function run(steps: PlanStep[], opts: { existing?: Record<string, string> } = {}): { batchId: string; items: Generation[]; byKey: Record<string, Generation> } {
try {
- return createPipeline(steps);
+ return createPipeline(steps, opts);
} catch (e) {
throw new ShortsError((e as Error).message, 422);
}