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.

Enhancer: Detail is 2× on the open engine too

Claudeeb80ed66815a
diff --git a/src/lib/layers.ts b/src/lib/layers.ts
index 5d12b70e..234bb919 100644
--- a/src/lib/layers.ts
+++ b/src/lib/layers.ts
@@ -270,12 +270,19 @@ export const ENHANCE_LOOKS: { id: EnhanceLook; label: string; verb: string; hint
hint: "Removes blur and noise, restores crisp edges",
prompt: "Sharpen the image: remove blur, noise and compression artefacts and restore crisp detail in edges, eyes, hair, fabric and text.",
},
- { id: "detail", label: "Detail", verb: "Restore detail", hint: "An upscaler rebuilds fine detail: twice the pixels, same place on the canvas" },
+ { id: "detail", label: "Detail", verb: "Restore detail", hint: "An upscaler rebuilds fine detail at twice the width and height, in the same place on the canvas" },
];
/** The upscalers behind the Detail look (the Upscale tool's, Topaz with its face pass first). */
export const ENHANCE_DETAIL_MODELS: { cloud: string[]; open: string[] } = { cloud: ["topaz-image", "seedvr-image"], open: ["oss-seedvr2-image", "oss-upscale-image"] };
+/**
+ * Detail is 2× on every engine: the cloud upscalers are 2× as listed (Topaz, SeedVR's upscale_factor),
+ * the open graphs default to 4× and take a `scale` (SeedVR2's output multiplier; ESRGAN's resize after
+ * its fixed 4×, so 0.5 nets 2×). A 2048-px layer would otherwise come back at 8192 px.
+ */
+export const ENHANCE_DETAIL_SCALE: Record<string, number> = { "oss-seedvr2-image": 2, "oss-upscale-image": 0.5 };
+
/** The models a look offers on an engine (the first is the default). */
export function enhanceModels(look: EnhanceLook | undefined, engine: "cloud" | "open"): string[] {
return look === "detail" ? ENHANCE_DETAIL_MODELS[engine] : TOOL_MODELS.enhance[engine];
diff --git a/src/server/layers.ts b/src/server/layers.ts
index 060fcd8b..0d06a9d6 100644
--- a/src/server/layers.ts
+++ b/src/server/layers.ts
@@ -9,6 +9,7 @@ import {
clampLayers,
CUTOUT_MODELS,
defaultLayers,
+ ENHANCE_DETAIL_SCALE,
enhanceModels,
enhancePrompt,
initialDoc,
@@ -347,8 +348,9 @@ export function jobSteps(input: LayerJobInput, opts: { batchTitle?: string } = {
const ask = enhancePrompt(look, prompt);
const model = toolModel(tool, engine, input.modelId, enhanceModels(look, engine));
if (!ask) {
- // Detail: an upscaler rebuilds it (the layer keeps its place with more pixels, as Upscale does).
- add("enhance", base(model, { op: "upscale-image", inputs: { images: [needImage()] }, params: aspectFor(model) }));
+ // Detail: an upscaler rebuilds it at 2× (the layer keeps its place with more pixels, as Upscale does).
+ const scale = ENHANCE_DETAIL_SCALE[model.id];
+ add("enhance", base(model, { op: "upscale-image", inputs: { images: [needImage()] }, params: { ...aspectFor(model), ...(scale ? { extra: { scale } } : {}) } }));
break;
}
add("enhance", base(model, { op: "edit", prompt: s.keepAlpha ? `${ask} Keep the subject on a plain, even background.` : ask, inputs: { images: [needImage()] }, params: aspectFor(model) }));
diff --git a/tests/layers-api.test.ts b/tests/layers-api.test.ts
index 47b63b41..68c93dcc 100644
--- a/tests/layers-api.test.ts
+++ b/tests/layers-api.test.ts
@@ -180,7 +180,10 @@ describe("job steps", () => {
const detail = steps({ tool: "enhance", settings: { look: "detail" } })[0].request;
expect(detail).toMatchObject({ modelId: "topaz-image", op: "upscale-image" });
expect(detail.prompt).toBeUndefined();
- expect(steps({ tool: "enhance", engine: "open", settings: { look: "detail" } })[0].request.modelId).toBe("oss-seedvr2-image");
+ // 2× on every engine: Topaz and SeedVR are 2× as listed, the open graphs (4× by default) get a scale.
+ expect(detail.params?.extra).toBeUndefined();
+ expect(steps({ tool: "enhance", engine: "open", settings: { look: "detail" } })[0].request).toMatchObject({ modelId: "oss-seedvr2-image", params: { extra: { scale: 2 } } });
+ expect(steps({ tool: "enhance", engine: "open", modelId: "oss-upscale-image", settings: { look: "detail" } })[0].request.params).toMatchObject({ extra: { scale: 0.5 } });
expect(() => steps({ tool: "enhance", modelId: "topaz-image", settings: { look: "skin" } })).toThrow(/can't run this tool/);
// A transparent layer gets its cut-out back after a retouch.
expect(steps({ tool: "enhance", settings: { look: "skin", keepAlpha: true } }).map((x) => x.key)).toEqual(["enhance", "cutout"]);
diff --git a/tests/layers-comfy.test.ts b/tests/layers-comfy.test.ts
index 025146a3..524801f9 100644
--- a/tests/layers-comfy.test.ts
+++ b/tests/layers-comfy.test.ts
@@ -93,6 +93,10 @@ describe("Inpaint and Enhancer on the open engine", () => {
expect(String(skin("prompt")[0])).toMatch(/^Give the portrait a subtle natural retouch/);
const detail = await bind(step({ tool: "enhance", settings: { look: "detail" } }));
expect(detail("image")).toEqual(["/api/files/a.png"]);
+ // 2×, not the graph's default 4×: SeedVR2's output multiplier, ESRGAN's resize after its fixed 4×.
+ expect(detail("scale")).toEqual([2]);
+ const esrgan = await bind(step({ tool: "enhance", modelId: "oss-upscale-image", settings: { look: "detail" } }));
+ expect(esrgan("scale")).toEqual([0.5]);
});
});
diff --git a/tests/layers.test.ts b/tests/layers.test.ts
index fee42c35..2e3b00fe 100644
--- a/tests/layers.test.ts
+++ b/tests/layers.test.ts
@@ -43,6 +43,7 @@ import {
TOOL_MODELS,
zipPlan,
ENHANCE_DETAIL_MODELS,
+ ENHANCE_DETAIL_SCALE,
ENHANCE_LOOKS,
elementDraft,
enhanceModels,
@@ -578,6 +579,8 @@ describe("tools and prices", () => {
);
// Every look but Detail has an instruction.
expect(ENHANCE_LOOKS.filter((l) => !l.prompt).map((l) => l.id)).toEqual(["detail"]);
+ // The open upscalers' 2× scales belong to Detail's own models.
+ expect(Object.keys(ENHANCE_DETAIL_SCALE).every((id) => ENHANCE_DETAIL_MODELS.open.includes(id))).toBe(true);
});
it("prices a decomposition per layer", () => {