fix(realtime-canvas): enforce sketch-preserving i2i defaults
This commit is contained in:
parent
80e826039f
commit
f25cfd3fab
@ -36,9 +36,9 @@ const defaultConfig = {
|
|||||||
model: {
|
model: {
|
||||||
id: "runware:101@1",
|
id: "runware:101@1",
|
||||||
defaults: {
|
defaults: {
|
||||||
steps: 4,
|
steps: 8,
|
||||||
cfgScale: 3.5,
|
cfgScale: 6,
|
||||||
strength: 0.85,
|
strength: 0.4,
|
||||||
imageSize: "square" as const,
|
imageSize: "square" as const,
|
||||||
},
|
},
|
||||||
limits: {
|
limits: {
|
||||||
@ -117,21 +117,18 @@ export async function GET() {
|
|||||||
defaultConfig.model.limits.steps.min,
|
defaultConfig.model.limits.steps.min,
|
||||||
defaultConfig.model.limits.steps.max
|
defaultConfig.model.limits.steps.max
|
||||||
);
|
);
|
||||||
|
const legacyScheduleMu = Number(config.defaults?.scheduleMu);
|
||||||
|
const cfgScaleBase = Number(
|
||||||
|
config.defaults?.cfgScale ??
|
||||||
|
(Number.isFinite(legacyScheduleMu) ? legacyScheduleMu * 2.5 : defaultConfig.model.defaults.cfgScale)
|
||||||
|
);
|
||||||
const cfgScale = clamp(
|
const cfgScale = clamp(
|
||||||
Number(
|
cfgScaleBase,
|
||||||
config.defaults?.cfgScale ??
|
|
||||||
config.defaults?.scheduleMu ??
|
|
||||||
defaultConfig.model.defaults.cfgScale
|
|
||||||
),
|
|
||||||
defaultConfig.model.limits.cfgScale.min,
|
defaultConfig.model.limits.cfgScale.min,
|
||||||
defaultConfig.model.limits.cfgScale.max
|
defaultConfig.model.limits.cfgScale.max
|
||||||
);
|
);
|
||||||
const strength = clamp(
|
const strength = clamp(
|
||||||
Number(
|
Number(config.defaults?.strength ?? defaultConfig.model.defaults.strength),
|
||||||
config.defaults?.strength ??
|
|
||||||
config.defaults?.feedback ??
|
|
||||||
defaultConfig.model.defaults.strength
|
|
||||||
),
|
|
||||||
defaultConfig.model.limits.strength.min,
|
defaultConfig.model.limits.strength.min,
|
||||||
defaultConfig.model.limits.strength.max
|
defaultConfig.model.limits.strength.max
|
||||||
);
|
);
|
||||||
|
|||||||
@ -115,23 +115,24 @@ export async function POST(request: Request) {
|
|||||||
const maxInputResolution = clamp(Number(config.maxInputResolution || 1024), 512, 1536);
|
const maxInputResolution = clamp(Number(config.maxInputResolution || 1024), 512, 1536);
|
||||||
const size = resolveSquareSize(body.imageSize, maxInputResolution);
|
const size = resolveSquareSize(body.imageSize, maxInputResolution);
|
||||||
const steps = clamp(
|
const steps = clamp(
|
||||||
Number(body.steps || config.defaults?.steps || 4),
|
Number(body.steps || config.defaults?.steps || 8),
|
||||||
1,
|
1,
|
||||||
8
|
8
|
||||||
);
|
);
|
||||||
const cfgScale = clamp(
|
const cfgScale = clamp(
|
||||||
Number(body.cfgScale || config.defaults?.cfgScale || 3.5),
|
Number(body.cfgScale || config.defaults?.cfgScale || 6),
|
||||||
1,
|
1,
|
||||||
12
|
12
|
||||||
);
|
);
|
||||||
const strength = clamp(
|
const strength = clamp(
|
||||||
Number(body.strength || config.defaults?.strength || 0.85),
|
Number(body.strength || config.defaults?.strength || 0.4),
|
||||||
0.05,
|
0.05,
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
|
|
||||||
const positivePrompt =
|
const positivePrompt =
|
||||||
String(body.prompt || "").trim() || "将草图渲染为高质感产品设计图,保持结构和主轮廓一致。";
|
String(body.prompt || "").trim() ||
|
||||||
|
"严格按照输入草图生成:保持主体轮廓、位置、比例和数量一致,只做材质与光影细化;禁止改变构图,禁止新增无关背景纹理。";
|
||||||
|
|
||||||
const requestInference = async (modelId: string) => {
|
const requestInference = async (modelId: string) => {
|
||||||
const taskUUID = crypto.randomUUID();
|
const taskUUID = crypto.randomUUID();
|
||||||
|
|||||||
@ -67,7 +67,8 @@ type RealtimeCanvasDialogProps = {
|
|||||||
onApplyResult: (payload: { imageUrl: string; prompt: string }) => void;
|
onApplyResult: (payload: { imageUrl: string; prompt: string }) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const FALLBACK_PROMPT = "将草图渲染为高质感产品设计图,保持结构和主轮廓一致。";
|
const FALLBACK_PROMPT =
|
||||||
|
"严格按照输入草图生成:保持主体轮廓、位置、比例和数量一致,只做材质与光影细化;禁止改变构图,禁止新增无关背景纹理。";
|
||||||
const CANVAS_BACKGROUND = "#ffffff";
|
const CANVAS_BACKGROUND = "#ffffff";
|
||||||
const BRUSH_COLOR_PRESETS = [
|
const BRUSH_COLOR_PRESETS = [
|
||||||
"#18181b",
|
"#18181b",
|
||||||
@ -91,9 +92,9 @@ const defaultRealtimeConfig: RealtimeConfig = {
|
|||||||
model: {
|
model: {
|
||||||
id: "runware:101@1",
|
id: "runware:101@1",
|
||||||
defaults: {
|
defaults: {
|
||||||
steps: 4,
|
steps: 8,
|
||||||
cfgScale: 3.5,
|
cfgScale: 6,
|
||||||
strength: 0.85,
|
strength: 0.4,
|
||||||
imageSize: "square",
|
imageSize: "square",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user