fix: skip scale adjust verification rejection
This commit is contained in:
parent
9e8817f89e
commit
39b4bd5983
@ -664,83 +664,14 @@ async function applyScaleAdjustVerificationToImages(params: {
|
|||||||
const { images, verification, debugLabel } = params;
|
const { images, verification, debugLabel } = params;
|
||||||
if (!verification || images.length === 0) return images;
|
if (!verification || images.length === 0) return images;
|
||||||
|
|
||||||
try {
|
console.info("[Canvas Generate Image] Scale adjust verification disabled:", {
|
||||||
const sourceImage = await loadScaleAdjustSourceImage(verification);
|
debugLabel,
|
||||||
if (!sourceImage) {
|
imageCount: images.length,
|
||||||
return images;
|
protectedRegionCount: verification.protectedRegions?.length || 0,
|
||||||
}
|
regionCount: verification.regions.length,
|
||||||
const { sourceBuffer, sourceHeight, sourceWidth } = sourceImage;
|
scalePercent: verification.scalePercent,
|
||||||
|
});
|
||||||
const checkedImages: ParsedImage[] = [];
|
return images;
|
||||||
for (const [index, image] of images.entries()) {
|
|
||||||
const generatedUrl = image.originalUrl || image.thumbnailUrl;
|
|
||||||
const generatedBuffer = Buffer.from(await fetchImageBufferFromUrl(generatedUrl));
|
|
||||||
const diffScores = await getScaleAdjustDiffScores({
|
|
||||||
generatedBuffer,
|
|
||||||
sourceBuffer,
|
|
||||||
sourceHeight,
|
|
||||||
sourceWidth,
|
|
||||||
regions: verification.regions,
|
|
||||||
});
|
|
||||||
const outsideDiffScores = await getScaleAdjustOutsideDiffScores({
|
|
||||||
generatedBuffer,
|
|
||||||
sourceBuffer,
|
|
||||||
sourceHeight,
|
|
||||||
sourceWidth,
|
|
||||||
verification,
|
|
||||||
});
|
|
||||||
const isVisuallyUnchanged =
|
|
||||||
diffScores.length > 0 &&
|
|
||||||
diffScores.every((score) => score < SCALE_ADJUST_VISUAL_DIFF_THRESHOLD);
|
|
||||||
const outsideChanged = isScaleAdjustOutsideChanged(outsideDiffScores);
|
|
||||||
|
|
||||||
if (!isVisuallyUnchanged && !outsideChanged) {
|
|
||||||
console.info("[Canvas Generate Image] Scale adjust output accepted:", {
|
|
||||||
debugLabel,
|
|
||||||
diffScores: diffScores.map((score) => Math.round(score * 10) / 10),
|
|
||||||
imageIndex: index + 1,
|
|
||||||
outsideDiffScores: outsideDiffScores.map(
|
|
||||||
(score) => Math.round(score * 10) / 10
|
|
||||||
),
|
|
||||||
protectedRegionCount: verification.protectedRegions?.length || 0,
|
|
||||||
scalePercent: verification.scalePercent,
|
|
||||||
});
|
|
||||||
checkedImages.push(image);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const rejection = new ScaleAdjustOutputRejectedError({
|
|
||||||
diffScores,
|
|
||||||
outsideDiffScores,
|
|
||||||
reason: outsideChanged ? "outside-frame-changed" : "unchanged-output",
|
|
||||||
});
|
|
||||||
console.warn("[Canvas Generate Image] Scale adjust output rejected:", {
|
|
||||||
debugLabel,
|
|
||||||
diffScores: diffScores.map((score) => Math.round(score * 10) / 10),
|
|
||||||
imageIndex: index + 1,
|
|
||||||
outsideDiffScores: outsideDiffScores.map(
|
|
||||||
(score) => Math.round(score * 10) / 10
|
|
||||||
),
|
|
||||||
protectedRegionCount: verification.protectedRegions?.length || 0,
|
|
||||||
reason: rejection.reason,
|
|
||||||
scalePercent: verification.scalePercent,
|
|
||||||
});
|
|
||||||
throw rejection;
|
|
||||||
}
|
|
||||||
|
|
||||||
return checkedImages;
|
|
||||||
} catch (error) {
|
|
||||||
if (error instanceof ScaleAdjustOutputRejectedError) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
console.warn("[Canvas Generate Image] Scale adjust verification skipped:", {
|
|
||||||
debugLabel,
|
|
||||||
error: error instanceof Error ? error.message : String(error),
|
|
||||||
regionCount: verification.regions.length,
|
|
||||||
scalePercent: verification.scalePercent,
|
|
||||||
});
|
|
||||||
return images;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildLocalEditCompositeMaskSvg(params: {
|
function buildLocalEditCompositeMaskSvg(params: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user