fix: prefer pixel structure for furniture scale edits
This commit is contained in:
parent
50a59b82af
commit
739dc091ab
@ -1349,6 +1349,13 @@ function isScaleAdjustPersonLikePrompt(prompt: string) {
|
||||
);
|
||||
}
|
||||
|
||||
function isScaleAdjustFurnitureProductLikePrompt(prompt: string) {
|
||||
const text = normalizeScaleAdjustModelText(prompt);
|
||||
return /furniture|product|object|chair|sofa|table|desk|cabinet|shelf|rack|lamp|cart|wheel|wood|woven|cane|rattan|panel|商品|产品|物体|家具|家居|椅|沙发|茶几|桌|柜|架|衣帽架|置物架|收纳|灯|车|轮|木|藤编|编织|面板|杆|挂包|帽子|伞/.test(
|
||||
text
|
||||
);
|
||||
}
|
||||
|
||||
function hasScaleAdjustPersonPixelSignal(params: {
|
||||
box: { left: number; top: number; width: number; height: number };
|
||||
raw: Buffer;
|
||||
@ -2438,6 +2445,7 @@ async function buildScaleAdjustRmbgStructureLockedComposite(params: {
|
||||
async function buildScaleAdjustStructureLockedComposite(params: {
|
||||
includePersonPixels?: boolean;
|
||||
placement: ReturnType<typeof getScaleAdjustVisualGuidePlacement>;
|
||||
preferPixelStructure?: boolean;
|
||||
raw: Buffer;
|
||||
sourceBuffer: Buffer;
|
||||
sourceImageUrl?: string;
|
||||
@ -2447,6 +2455,7 @@ async function buildScaleAdjustStructureLockedComposite(params: {
|
||||
const {
|
||||
includePersonPixels = false,
|
||||
placement,
|
||||
preferPixelStructure = false,
|
||||
raw,
|
||||
sourceBuffer,
|
||||
sourceImageUrl,
|
||||
@ -2455,9 +2464,10 @@ async function buildScaleAdjustStructureLockedComposite(params: {
|
||||
} = params;
|
||||
// The current RMBG provider can bake horizontal matte stripes into furniture cutouts.
|
||||
const allowRmbgStructureLock =
|
||||
process.env.CANVAS_SCALE_ADJUST_ENABLE_RMBG_STRUCTURE === "1" ||
|
||||
(includePersonPixels &&
|
||||
process.env.CANVAS_SCALE_ADJUST_DISABLE_PERSON_RMBG !== "1");
|
||||
!preferPixelStructure &&
|
||||
(process.env.CANVAS_SCALE_ADJUST_ENABLE_RMBG_STRUCTURE === "1" ||
|
||||
(includePersonPixels &&
|
||||
process.env.CANVAS_SCALE_ADJUST_DISABLE_PERSON_RMBG !== "1"));
|
||||
const rmbgComposite = !allowRmbgStructureLock
|
||||
? null
|
||||
: await buildScaleAdjustRmbgStructureLockedComposite({
|
||||
@ -2768,16 +2778,25 @@ async function buildScaleAdjustVisualLayoutGuideBuffer(params: {
|
||||
targetHeightFactor > 1.08 ||
|
||||
targetWidthFactor < 0.92 ||
|
||||
targetHeightFactor < 0.92);
|
||||
const preferPixelStructure = isScaleAdjustFurnitureProductLikePrompt(
|
||||
region.prompt
|
||||
);
|
||||
const hasPersonPixels =
|
||||
!preferPixelStructure &&
|
||||
!!sourceRaw &&
|
||||
hasScaleAdjustPersonPixelSignal({
|
||||
box: placement.sourceBox,
|
||||
raw: sourceRaw,
|
||||
width: sourceWidth,
|
||||
});
|
||||
const includePersonPixels =
|
||||
!preferPixelStructure &&
|
||||
(isScaleAdjustPersonLikePrompt(region.prompt) || hasPersonPixels);
|
||||
const structureLockedComposite = shouldUseStructureLock
|
||||
? await buildScaleAdjustStructureLockedComposite({
|
||||
includePersonPixels:
|
||||
isScaleAdjustPersonLikePrompt(region.prompt) ||
|
||||
hasScaleAdjustPersonPixelSignal({
|
||||
box: placement.sourceBox,
|
||||
raw: sourceRaw,
|
||||
width: sourceWidth,
|
||||
}),
|
||||
includePersonPixels,
|
||||
placement,
|
||||
preferPixelStructure,
|
||||
raw: sourceRaw,
|
||||
sourceBuffer,
|
||||
sourceImageUrl,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user