fix: preserve people during scale enlargement
This commit is contained in:
parent
4f5a986162
commit
e0e57c6865
@ -614,6 +614,20 @@ function getScaleAdjustTargetRect(
|
||||
return region.rect;
|
||||
}
|
||||
|
||||
function hasScaleAdjustEnlargeTarget(
|
||||
regions: NormalizedLocalEditRegion[],
|
||||
scalePercent?: ScaleAdjustPercent | null
|
||||
) {
|
||||
return regions.some((region) => {
|
||||
const targetRect = getScaleAdjustTargetRect(region, scalePercent);
|
||||
const widthFactor =
|
||||
region.rect.width > 0 ? targetRect.width / region.rect.width : 1;
|
||||
const heightFactor =
|
||||
region.rect.height > 0 ? targetRect.height / region.rect.height : 1;
|
||||
return widthFactor > 1.08 || heightFactor > 1.08;
|
||||
});
|
||||
}
|
||||
|
||||
function expandRectWithMargins(
|
||||
rect: NormalizedLocalEditRegion["rect"],
|
||||
marginX: number,
|
||||
@ -2081,7 +2095,7 @@ function buildScaleAdjustPatchPrompt(
|
||||
: "Input image 1 is the exact crop from the original photo and is the locked crop base.";
|
||||
const secondInputRole = targetDraftPrimary
|
||||
? includeSourceReference
|
||||
? "Input image 2 is the original clean crop. Use it only for stable crop framing, background texture, lighting, perspective, and furniture identity. Do not restore the selected furniture to its old larger size from this image."
|
||||
? "Input image 2 is the original clean crop. Use it for stable crop framing, background texture, lighting, perspective, furniture identity, and non-target human/person preservation. Do not restore the selected furniture to its old size from this image."
|
||||
: ""
|
||||
: "Input image 2 is a rough target-layout draft of the same crop. It is the hard layout target for the selected furniture size and position. Use it to understand the final footprint and newly visible background area, then remove any rough seams, washed areas, placeholder shadows, blur, or patch artifacts from that draft.";
|
||||
const cropLines = cropReferences
|
||||
@ -2132,15 +2146,17 @@ function buildScaleAdjustPatchPrompt(
|
||||
secondInputRole,
|
||||
cropLines,
|
||||
"Only edit the selected movable furniture subject. Keep the crop borders, wall, window frame, floor, rug, sofa, lamps, decor, lighting, camera perspective, and all non-target furniture stable.",
|
||||
"If people, faces, arms, hands, bodies, hair, or worn clothing appear in the crop, they are not furniture. Preserve the human scale, identity, pose, face, hand shape, and clothing position as much as possible; do not enlarge, shrink, duplicate, or redraw the person as part of the furniture scale edit.",
|
||||
"When the final footprint is smaller, the selected furniture must clearly shrink; erase the old larger furniture footprint outside the final footprint and replace it with natural background/floor/rug/wall/shadow that matches the original crop.",
|
||||
"When the final footprint is larger, enlarge the selected furniture itself to match the target draft while keeping nearby people and hands natural. If a hand touches or holds an item on the furniture, keep the hand anatomically plausible and use the original crop as the person-preservation reference.",
|
||||
"Keep the same furniture identity, material, perspective, object details, contact shadows, and natural aspect ratio. Do not stretch, squash, duplicate, or replace it with a different item.",
|
||||
"Hard failure condition: if the selected furniture remains near its original old size, the answer is wrong. The output must visibly reduce the furniture footprint to the target draft footprint.",
|
||||
"Hard failure condition: if the selected furniture remains near its original old size, the answer is wrong. The output must visibly change the furniture footprint to match the target draft footprint.",
|
||||
"Do not output boxes, lines, labels, coordinate marks, UI marks, text, arrows, overlays, rough layout artifacts, rectangular patch edges, or a full-room image.",
|
||||
targetDraftPrimary
|
||||
? includeSourceReference
|
||||
? "中文硬约束:输入图1是目标大小/位置草稿,必须按它的小尺寸家具布局输出;输入图2只是原始质感和背景参考,绝对不要把家具恢复成输入图2里的旧大尺寸。只输出同一裁切范围的干净局部照片,去掉草稿中的泛白、残影和拼接感。"
|
||||
: "中文硬约束:输入图1是唯一视觉参考和目标大小/位置草稿,必须按它的小尺寸家具布局输出。不要找回旧尺寸家具。只输出同一裁切范围的干净局部照片,去掉草稿中的泛白、残影和拼接感。"
|
||||
: "中文硬约束:只输出输入图1同一裁切范围的干净局部照片;输入图2是目标大小/位置草稿,必须按它的小尺寸家具布局输出,不是要保留旧尺寸。目标家具必须相对原图产生明显比例变化,非目标背景和裁切边缘要稳定自然。",
|
||||
? "中文硬约束:输入图1是目标大小/位置草稿,必须按它的目标尺寸和目标位置输出;输入图2只是原始质感、人物和背景参考,绝对不要把家具恢复成输入图2里的旧尺寸。只输出同一裁切范围的干净局部照片,去掉草稿中的泛白、残影和拼接感。"
|
||||
: "中文硬约束:输入图1是唯一视觉参考和目标大小/位置草稿,必须按它的目标尺寸和目标位置输出。不要找回旧尺寸家具。只输出同一裁切范围的干净局部照片,去掉草稿中的泛白、残影和拼接感。"
|
||||
: "中文硬约束:只输出输入图1同一裁切范围的干净局部照片;输入图2是目标大小/位置草稿,必须按它的目标尺寸和目标位置输出,不是要保留旧尺寸。目标家具必须相对原图产生明显比例变化,非目标背景和裁切边缘要稳定自然。",
|
||||
"",
|
||||
"Region instructions:",
|
||||
regionLines,
|
||||
@ -2431,7 +2447,9 @@ export async function POST(request: NextRequest) {
|
||||
})
|
||||
: [];
|
||||
const useScaleAdjustPatchTargetDraftPrimary = Boolean(scaleAdjustPatchReference);
|
||||
const includeScaleAdjustPatchSourceReference = false;
|
||||
const includeScaleAdjustPatchSourceReference =
|
||||
Boolean(scaleAdjustPatchReference) &&
|
||||
hasScaleAdjustEnlargeTarget(regions, scalePercent);
|
||||
const prompt = isScaleAdjustOperation
|
||||
? scaleAdjustPatchReference
|
||||
? buildScaleAdjustPatchPrompt(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user