fix: use coordinate map for scale adjust
This commit is contained in:
parent
22b007c2d9
commit
6f0fb9fe4b
@ -1438,11 +1438,11 @@ function buildScaleAdjustCoordinatePrompt(
|
||||
"中文硬约束:只调整 OLD 框中的主要家具主体。TARGET 框是最终占位;如果是缩小,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 full-frame semantic edit map with the same canvas as input image 1, not output content and not a photo layer. It keeps the original room frame visible as the locked reference, strongly fades the OLD source footprint to mean remove/heal the old full-size furniture, and shows the same furniture at the required TARGET footprint. Read only the final furniture footprint, center, and locked frame relationship from input image 2. If any original-size furniture is still faintly visible in the faded OLD area, treat it as removed in the final; the final must contain only the TARGET-size furniture. Never copy faded wash, placeholder shadow, rectangular crop edges, rough patch quality, seams, or guide artifacts into the output.",
|
||||
"Input image 2 is a neutral coordinate instruction map, not a photo and not output content. The OLD box/label locates the current furniture in input image 1; the TARGET box/label gives the required final footprint, center, and scale factor. If the map says OLD OUTSIDE = BACKGROUND, the old full-size furniture outside TARGET must disappear and be healed as natural background in the final photo. Read the boxes, labels, arrows, and scale text only as instructions; never output any map graphics.",
|
||||
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 layout shown in input image 2 and the numeric TARGET coordinates below.",
|
||||
"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 shown in input image 2 and the numeric TARGET coordinates below.",
|
||||
"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.",
|
||||
@ -1454,8 +1454,8 @@ function buildScaleAdjustCoordinatePrompt(
|
||||
"Region requirements:",
|
||||
regionLines,
|
||||
"",
|
||||
"Success check: compare the final furniture footprint with input image 1 and the full-frame semantic edit map in input image 2. The selected furniture size must clearly change from the original and align much closer to TARGET than OLD, while the rest of the photo stays stable.",
|
||||
"Do not paste rectangular image areas. Do not output layout-reference overlays, muted wash, coordinate-map lines, labels, boxes, seams, hard patch edges, haze, color mismatch, full-canvas zoom, crop, pan, or redesign.",
|
||||
"Success check: compare the final furniture footprint with input image 1 and the neutral coordinate map in input image 2. The selected furniture size must clearly change from the original and align much closer to TARGET than OLD, while the rest of the photo stays stable.",
|
||||
"Do not paste rectangular image areas. Do not output coordinate-map lines, labels, boxes, arrows, scale text, muted wash, overlays, seams, hard patch edges, haze, color mismatch, full-canvas zoom, crop, pan, or redesign.",
|
||||
"Return only the clean edited photo.",
|
||||
].join("\n");
|
||||
}
|
||||
@ -1463,7 +1463,7 @@ function buildScaleAdjustCoordinatePrompt(
|
||||
function buildScaleAdjustCoordinateSystemPrompt() {
|
||||
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 full-frame semantic edit map, not a photo layer.",
|
||||
"Input image 1 is the only final photo base. Input image 2 is a neutral 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.",
|
||||
@ -1638,13 +1638,25 @@ export async function POST(request: NextRequest) {
|
||||
resolvedScaleAdjustModelEntry
|
||||
);
|
||||
const annotatedBuffer = isScaleAdjustOperation
|
||||
? await buildScaleAdjustVisualLayoutGuideBuffer({
|
||||
regions,
|
||||
scalePercent,
|
||||
sourceBuffer,
|
||||
sourceHeight,
|
||||
sourceWidth,
|
||||
})
|
||||
? useScaleAdjustCoordinateGuide
|
||||
? await sharp(
|
||||
buildScaleAdjustAnnotationSvg({
|
||||
height: sourceHeight,
|
||||
regions,
|
||||
scalePercent,
|
||||
width: sourceWidth,
|
||||
}),
|
||||
{ failOn: "none" }
|
||||
)
|
||||
.png({ compressionLevel: 6 })
|
||||
.toBuffer()
|
||||
: await buildScaleAdjustVisualLayoutGuideBuffer({
|
||||
regions,
|
||||
scalePercent,
|
||||
sourceBuffer,
|
||||
sourceHeight,
|
||||
sourceWidth,
|
||||
})
|
||||
: await sharp(sourceBuffer, { failOn: "none" })
|
||||
.composite([
|
||||
{
|
||||
@ -1739,7 +1751,9 @@ export async function POST(request: NextRequest) {
|
||||
annotatedReferenceUrl: annotatedUpload.url,
|
||||
annotatedReferenceSentToModel: isScaleAdjustOperation,
|
||||
annotatedReferenceType: isScaleAdjustOperation
|
||||
? "scale-adjust-full-frame-semantic-edit-map"
|
||||
? useScaleAdjustCoordinateGuide
|
||||
? "scale-adjust-neutral-coordinate-map"
|
||||
: "scale-adjust-full-frame-semantic-edit-map"
|
||||
: "source-overlay",
|
||||
cleanSourceReferenceIndex: 1,
|
||||
configuredDetailModelId: configuredDetailModel || null,
|
||||
@ -1754,7 +1768,10 @@ export async function POST(request: NextRequest) {
|
||||
resolvedScaleAdjustModelEntry?.provider?.type || null,
|
||||
scaleAdjustModelFamily: scaleAdjustModelFamily || null,
|
||||
scaleAdjustCoordinateGuideApplied: useScaleAdjustCoordinateGuide,
|
||||
scaleAdjustVisualLayoutGuideApplied: isScaleAdjustOperation,
|
||||
scaleAdjustNeutralCoordinateMapApplied:
|
||||
isScaleAdjustOperation && useScaleAdjustCoordinateGuide,
|
||||
scaleAdjustVisualLayoutGuideApplied:
|
||||
isScaleAdjustOperation && !useScaleAdjustCoordinateGuide,
|
||||
falScaleAdjustCoordinateGuideApplied:
|
||||
useScaleAdjustCoordinateGuide &&
|
||||
resolvedScaleAdjustModelEntry?.provider?.type === "fal-image",
|
||||
@ -1783,7 +1800,7 @@ export async function POST(request: NextRequest) {
|
||||
.length,
|
||||
scaleAdjustPromptStrategy: isScaleAdjustOperation
|
||||
? useScaleAdjustCoordinateGuide
|
||||
? "same-name-locked-source-semantic-target-map-no-old-crop-v38-one-shot"
|
||||
? "same-name-neutral-coordinate-map-no-old-crop-v39-one-shot"
|
||||
: "locked-plate-semantic-target-map-no-old-crop-v15"
|
||||
: undefined,
|
||||
scaleAdjustPostCompositeApplied: false,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user