fix(inpaint): zero out mask in LaMa FFC input tensor and lock mobile col-main chip row to 52px

This commit is contained in:
2026-10-17 12:18:30 +07:00
parent 194a89f89a
commit 7c6baa6319
4 changed files with 66 additions and 16 deletions
+9 -7
View File
@@ -145,7 +145,9 @@ export async function runServerInpaint(
const resizedImg = resizeBilinear(rawRgb, w, h, scaledW, scaledH, 3);
const resizedMask = resizeBilinear(rawMask, w, h, scaledW, scaledH, 1);
// Pad into side x side buffer with edge replication for image and 0 for mask
// Pad into side x side buffer with edge replication for image and 0 for mask.
// CRITICAL FOR LAMA FFC: X_input = I * (1 - M). The pixels inside the mask must be
// zeroed out (0.0) before passing into the network to eliminate frequency resonance starbursts.
const inImage = new Float32Array(3 * side * side);
const inMask = new Float32Array(side * side);
@@ -156,13 +158,13 @@ export async function runServerInpaint(
const dstIdx = y * side + x;
const srcIdx = sy * scaledW + sx;
inImage[dstIdx] = resizedImg[srcIdx];
inImage[side * side + dstIdx] = resizedImg[scaledW * scaledH + srcIdx];
inImage[2 * side * side + dstIdx] = resizedImg[2 * scaledW * scaledH + srcIdx];
const isHole = (y < scaledH && x < scaledW && resizedMask[srcIdx] > 0.15) ? 1.0 : 0.0;
inMask[dstIdx] = isHole;
if (y < scaledH && x < scaledW) {
inMask[dstIdx] = resizedMask[srcIdx] > 0.15 ? 1.0 : 0.0;
}
const keep = 1.0 - isHole;
inImage[dstIdx] = resizedImg[srcIdx] * keep;
inImage[side * side + dstIdx] = resizedImg[scaledW * scaledH + srcIdx] * keep;
inImage[2 * side * side + dstIdx] = resizedImg[2 * scaledW * scaledH + srcIdx] * keep;
}
}
+2
View File
@@ -929,6 +929,8 @@ export async function inpaintCrop(
patchCache.set(aiKey, aiPatch.slice());
return aiPatch;
}
} else if (res) {
console.warn(`[inpaint] AI server returned ${res.status} ${res.statusText}. Falling back to local engine.`);
}
} catch (err) {
console.warn('[inpaint] server AI request error, using local engine patch:', err);
+54 -8
View File
@@ -2571,12 +2571,36 @@ form[data-key='immich-modal'] {
paint over the ones beside them. */
.col-main > *, .col-sub:not(.wm-extra) > * { flex: 0 0 auto !important; }
.col-main:not(.col-create) .chip-row,
.col-main:not(.col-create) .chip-row.list,
.col-sub:not(.wm-extra) .chip-row {
display: flex !important;
flex-direction: row !important;
align-items: center !important;
flex-wrap: nowrap !important;
height: 100% !important;
min-width: 100% !important;
width: max-content !important;
gap: 6px !important;
}
.col-main:not(.col-create) .chip,
.col-main:not(.col-create) .chip-row.list .chip {
flex: 0 0 auto !important;
width: auto !important;
white-space: nowrap !important;
display: inline-flex !important;
align-items: center !important;
height: 36px !important;
padding: 0 12px !important;
border-radius: 999px !important;
border: 1px solid var(--border) !important;
background: var(--bg-sunken) !important;
}
.col-main:not(.col-create) .chip[aria-pressed="true"],
.col-main:not(.col-create) .chip-row.list .chip[aria-pressed="true"] {
background: var(--accent-soft) !important;
border-color: var(--accent-line) !important;
color: var(--accent) !important;
}
.col-main .chip { flex: 0 0 auto !important; width: auto !important; }
/* The rule a strip is read across runs the other way here: in a row of chips
it divides the line, it does not break it. */
.col-main .chip-rule { flex: 0 0 auto !important; width: 1px !important; height: 18px !important; margin: 0 3px !important; }
@@ -2585,6 +2609,7 @@ form[data-key='immich-modal'] {
other tab (it and this row call the same reset), so the row only survives
where the button does something the topbar's does not: CREATE's form. */
.reset-row { display: none !important; }
.col-main .col-grip { display: none !important; }
.col-create .reset-row { display: block !important; margin: 0; padding: 0 0 0 8px; border-top: none; border-left: 1px solid var(--border); }
/* CREATE's form is not a strip of chips: it keeps the column's shape and
scrolls down instead of across, in the bar's place. */
@@ -3102,12 +3127,8 @@ form[data-key='immich-modal'] {
off-screen, and what the visitor saw of a chip was its label alone in an
empty pill. A chip here is as wide as its own label, and a strip as tall as
the chips it holds. */
.workspace.is-mobile .col,
.workspace.is-mobile .col-main,
.workspace.is-mobile .col-sub,
.workspace.is-mobile .col[data-col="slider"],
.workspace.is-mobile .col-create,
.workspace.is-mobile .col-slider {
.workspace.is-mobile .col-slider,
.workspace.is-mobile .col-create {
height: auto !important;
}
.workspace.is-mobile .col .chip {
@@ -3162,14 +3183,39 @@ form[data-key='immich-modal'] {
flex: 0 1 auto !important;
}
.workspace.is-mobile .col-main:not(.col-create) .chip-row,
.workspace.is-mobile .col-main:not(.col-create) .chip-row.list,
.workspace.is-mobile .col-sub:not(.wm-extra) .chip-row {
min-width: 100% !important;
width: max-content !important;
flex-wrap: nowrap !important;
flex-direction: row !important;
align-items: center !important;
height: 100% !important;
display: flex !important;
gap: 6px !important;
}
.workspace.is-mobile .col-grip {
.workspace.is-mobile .col-main:not(.col-create) .chip,
.workspace.is-mobile .col-main:not(.col-create) .chip-row.list .chip {
flex: 0 0 auto !important;
width: auto !important;
white-space: nowrap !important;
display: inline-flex !important;
align-items: center !important;
height: 36px !important;
padding: 0 12px !important;
border-radius: 999px !important;
border: 1px solid var(--border) !important;
background: var(--bg-sunken) !important;
}
.workspace.is-mobile .col-main:not(.col-create) .chip[aria-pressed="true"],
.workspace.is-mobile .col-main:not(.col-create) .chip-row.list .chip[aria-pressed="true"] {
background: var(--accent-soft) !important;
border-color: var(--accent-line) !important;
color: var(--accent) !important;
}
.workspace.is-mobile .col-grip,
.workspace.is-mobile .col-main .col-grip,
.workspace.is-mobile .col-main:not(.col-create) .reset-row {
display: none !important;
}
.workspace.is-mobile .save-hint {
+1 -1
View File
@@ -1 +1 @@
b00e823e83ef29a57ba7f479edcc89de34fc2dd9bec7d796ba95cbfa680da7a2 recipescam-images.tar.gz
cc2654854d18fb42ae4ab57972171dad241ba4b06447b7fc30e632529400f39a recipescam-images.tar.gz