fix: accept visual shrink scale edits
This commit is contained in:
parent
48a0f2ee73
commit
6baeb57cde
@ -2625,10 +2625,9 @@ async function createScaleAdjustPatchReference(params: {
|
|||||||
} = params;
|
} = params;
|
||||||
const workspaceRect = getScaleAdjustPatchWorkspaceRect(regions, scalePercent);
|
const workspaceRect = getScaleAdjustPatchWorkspaceRect(regions, scalePercent);
|
||||||
const workspacePixelRect = rectToPixels(workspaceRect, sourceWidth, sourceHeight);
|
const workspacePixelRect = rectToPixels(workspaceRect, sourceWidth, sourceHeight);
|
||||||
const structureLockedDraft = hasScaleAdjustStructureTarget(
|
// Pixel-mask structure drafts are useful for enlargement, but in shrink
|
||||||
regions,
|
// cases they can turn dense interior details into black mask blocks.
|
||||||
scalePercent
|
const structureLockedDraft = hasScaleAdjustEnlargeTarget(regions, scalePercent);
|
||||||
);
|
|
||||||
const targetDraftBuffer = await buildScaleAdjustVisualLayoutGuideBuffer({
|
const targetDraftBuffer = await buildScaleAdjustVisualLayoutGuideBuffer({
|
||||||
regions,
|
regions,
|
||||||
scalePercent,
|
scalePercent,
|
||||||
|
|||||||
@ -189,6 +189,7 @@ const SCALE_ADJUST_MARKER_CLEANUP_MARGIN = 0.035;
|
|||||||
const SCALE_ADJUST_MARKER_DILATE_RADIUS = 3;
|
const SCALE_ADJUST_MARKER_DILATE_RADIUS = 3;
|
||||||
const SCALE_ADJUST_MARKER_MIN_PIXEL_COUNT = 18;
|
const SCALE_ADJUST_MARKER_MIN_PIXEL_COUNT = 18;
|
||||||
const SCALE_ADJUST_DIFF_SAMPLE_SIZE = 112;
|
const SCALE_ADJUST_DIFF_SAMPLE_SIZE = 112;
|
||||||
|
const SCALE_ADJUST_FOOTPRINT_FALLBACK_DIFF_THRESHOLD = 18;
|
||||||
const SCALE_ADJUST_FALLBACK_MASK_DISTANCE_THRESHOLD = 42;
|
const SCALE_ADJUST_FALLBACK_MASK_DISTANCE_THRESHOLD = 42;
|
||||||
const SCALE_ADJUST_FALLBACK_MASK_LUMA_GAP = 18;
|
const SCALE_ADJUST_FALLBACK_MASK_LUMA_GAP = 18;
|
||||||
const SCALE_ADJUST_FALLBACK_INPAINT_ITERATIONS = 180;
|
const SCALE_ADJUST_FALLBACK_INPAINT_ITERATIONS = 180;
|
||||||
@ -1582,7 +1583,15 @@ async function applyScaleAdjustVerificationToImages(params: {
|
|||||||
const visuallyChangedInside = changeDiffScores.some(
|
const visuallyChangedInside = changeDiffScores.some(
|
||||||
(score) => score >= SCALE_ADJUST_VISUAL_DIFF_THRESHOLD
|
(score) => score >= SCALE_ADJUST_VISUAL_DIFF_THRESHOLD
|
||||||
);
|
);
|
||||||
const changedInside = visuallyChangedInside && footprintStats.passed;
|
const footprintFallbackAccepted =
|
||||||
|
visuallyChangedInside &&
|
||||||
|
!footprintStats.passed &&
|
||||||
|
changeDiffScores.some(
|
||||||
|
(score) => score >= SCALE_ADJUST_FOOTPRINT_FALLBACK_DIFF_THRESHOLD
|
||||||
|
);
|
||||||
|
const changedInside =
|
||||||
|
(visuallyChangedInside && footprintStats.passed) ||
|
||||||
|
footprintFallbackAccepted;
|
||||||
const outsideChanged =
|
const outsideChanged =
|
||||||
isScaleAdjustOutsideChanged(outsideDiffScores) ||
|
isScaleAdjustOutsideChanged(outsideDiffScores) ||
|
||||||
isScaleAdjustOutsidePixelChanged(outsidePixelStats);
|
isScaleAdjustOutsidePixelChanged(outsidePixelStats);
|
||||||
@ -1591,6 +1600,7 @@ async function applyScaleAdjustVerificationToImages(params: {
|
|||||||
console.info("[Canvas Generate Image] Scale adjust result guard:", {
|
console.info("[Canvas Generate Image] Scale adjust result guard:", {
|
||||||
debugLabel,
|
debugLabel,
|
||||||
changedInside,
|
changedInside,
|
||||||
|
footprintFallbackAccepted,
|
||||||
footprintChanged: footprintStats.passed,
|
footprintChanged: footprintStats.passed,
|
||||||
footprintStats: {
|
footprintStats: {
|
||||||
failedRegionCount: footprintStats.failedRegionCount,
|
failedRegionCount: footprintStats.failedRegionCount,
|
||||||
@ -1669,6 +1679,7 @@ async function applyScaleAdjustVerificationToImages(params: {
|
|||||||
imageIndex: index,
|
imageIndex: index,
|
||||||
reasons: guardWarnings,
|
reasons: guardWarnings,
|
||||||
changedInside,
|
changedInside,
|
||||||
|
footprintFallbackAccepted,
|
||||||
footprintChanged: footprintStats.passed,
|
footprintChanged: footprintStats.passed,
|
||||||
footprintStats: {
|
footprintStats: {
|
||||||
failedRegionCount: footprintStats.failedRegionCount,
|
failedRegionCount: footprintStats.failedRegionCount,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user