fix: tune fal scale adjust prompt

This commit is contained in:
134 2026-07-01 23:41:34 +08:00
parent 69f2f7957d
commit f5a409fdde

View File

@ -792,16 +792,12 @@ function buildScaleAdjustAnnotationSvg(params: {
const heightFactor = source.height > 0 ? target.height / source.height : 1;
const isShrink = widthFactor < 0.92 || heightFactor < 0.92;
const isEnlarge = widthFactor > 1.08 || heightFactor > 1.08;
const actionLabel = isShrink
? "SHRINK SUBJECT"
: isEnlarge
? "ENLARGE SUBJECT"
: "MOVE SUBJECT";
const actionLabel = isShrink ? "SHRINK" : isEnlarge ? "ENLARGE" : "MOVE";
const scaleLabel = `${actionLabel} ${widthFactor.toFixed(2)}W ${heightFactor.toFixed(2)}H`;
const instructionLabel = isShrink
? "HEAL OLD AREA OUTSIDE TARGET"
? "OLD OUTSIDE = BACKGROUND"
: isEnlarge
? "FINAL SUBJECT MAY EXPAND HERE"
? "TARGET = FINAL FOOTPRINT"
: "FINAL SUBJECT CENTER";
const centerMoved =
Math.hypot(targetCenterX - sourceCenterX, targetCenterY - sourceCenterY) >
@ -1022,16 +1018,19 @@ function buildFalScaleAdjustCoordinatePrompt(
return [
"Local furniture scale edit. Use input image 1 as the clean original photo and the locked camera frame.",
"中文硬约束:只调整 OLD 框中的主要家具主体。TARGET 框是最终占位;如果是缩小,OLD 框里超出 TARGET 的旧家具必须消失并补成自然背景;如果是放大,同一件家具必须明显变大。禁止整图缩放、整图裁切、整图重绘。",
`Return one seamless realistic photo with the same frame and pixel size as input image 1: ${sourceSize.width} x ${sourceSize.height} px.`,
"Input image 2 is a separate neutral coordinate instruction map, not a photo and not output content. The light gray OLD rectangle/label locates the current furniture in input image 1; the dark TARGET rectangle/label gives the required final size and center. The map may include arrows, scale-factor text, HEAL OLD AREA, and FINAL SUBJECT AREA labels: read them as instructions only, never as visual content.",
"Input image 2 is a separate neutral coordinate instruction map, not a photo and not output content. The light gray OLD rectangle/label locates the current furniture in input image 1; the dark TARGET rectangle/label gives the required final size and center. The map may include arrows, scale-factor text, OLD OUTSIDE = BACKGROUND, and TARGET = FINAL FOOTPRINT labels: read them as instructions only, never as visual content.",
cropLines ? `${cropLines}` : "",
"",
"Task:",
"Find the main movable furniture subject inside each OLD box in input image 1. Resize and, if needed, move that subject only so its final visible footprint matches the TARGET box.",
"Do a real subject-scale edit, not a full image zoom. The camera, room layout, windows, wall decor, text, floor, rug, and all non-target furniture must remain stable.",
"If an OLD box contains more than one object, choose the dominant furniture/product inside that box, usually the largest or most central movable item. Keep adjacent lamps, plants, side tables, pillows, wall decor, windows, text, and background objects at their original size unless they are clearly part of the same furniture subject.",
"Keep the furniture identity, material, perspective, objects on top, and natural aspect ratio from input image 1. Do not create a second copy or extra parts. Do not preserve the original furniture size just because the scene looks realistic; the user explicitly wants a visible scale change.",
"For beds, sofas, tables, chairs, cabinets, benches, and other large furniture, still perform the scale edit on that furniture. Do not treat large furniture as locked architecture.",
"If the target is smaller, the furniture must visibly become smaller and be mostly contained by the TARGET footprint. The OLD area outside the TARGET footprint must no longer contain the full-size furniture; naturally heal newly exposed floor, rug, wall, bedding, shadows, and background. If the target is larger, enlarge the same furniture naturally without stretching it.",
"缩小时请优先让目标家具明显缩小,而不是为了保守而保持原样。原尺寸保留、只轻微变形、或只改变整张图构图都算失败。",
"Never keep the selected furniture at its original footprint. If the edited furniture still fills the OLD rectangle instead of the TARGET rectangle, the result is invalid.",
"",
"Region requirements:",
@ -1047,6 +1046,7 @@ function buildFalScaleAdjustSystemPrompt() {
return [
"You are an image editing model for local furniture scale adjustment.",
"Input image 1 is the only final photo base. Input image 2 is a coordinate instruction map, not a photo layer.",
"Follow both English and Chinese instructions. The Chinese lines are hard constraints for avoiding unchanged furniture and full-canvas zoom.",
"Generate a clean realistic final photo by editing the target furniture itself and naturally rebuilding only the tiny surrounding background that becomes visible.",
"Prefer a clear visible size change over a conservative unchanged result; unchanged furniture is a failed edit.",
"When shrinking, remove the old full-size furniture footprint outside the target footprint and heal it as natural background. Large furniture is editable and must not remain locked at original size.",
@ -1349,7 +1349,7 @@ export async function POST(request: NextRequest) {
.length,
scaleAdjustPromptStrategy: isScaleAdjustOperation
? useFalScaleAdjustCoordinateGuide
? "fal-locked-source-neutral-coordinate-map-v27-action-heal-guide"
? "fal-locked-source-neutral-coordinate-map-v29-bilingual-high-thinking"
: "locked-plate-neutral-coordinate-guide-map-pixel-anchors-v8"
: undefined,
scaleAdjustPostCompositeApplied: false,
@ -1362,7 +1362,7 @@ export async function POST(request: NextRequest) {
falSafetyTolerance: useFalScaleAdjustCoordinateGuide ? "6" : undefined,
falSystemPrompt:
useFalScaleAdjustCoordinateGuide ? buildFalScaleAdjustSystemPrompt() : undefined,
falThinkingLevel: undefined,
falThinkingLevel: useFalScaleAdjustCoordinateGuide ? "high" : undefined,
allowFailover: useFalScaleAdjustCoordinateGuide ? false : undefined,
imageCount: 1,
imageSize: