feat(tools): publish Group 3 (SDXL Inpainting) and Group 5 (Portrait & Multi-Face) tools with live specimens

This commit is contained in:
2026-11-12 16:28:52 +05:30
parent 58094db11d
commit 5db8abf037
69 changed files with 865 additions and 680 deletions
+28
View File
@@ -145,6 +145,25 @@ export async function executeBackendTryIt(
const maskParamName = maskParam?.name || 'mask_image';
const maskBlob = new Blob([new Uint8Array(effectiveMask)]);
formData.append(maskParamName, maskBlob, options.maskFilename || 'mask.png');
} else {
// If endpoint requires a mask file and no mask was provided, synthesize an appropriate fallback mask
const maskParam = endpoint.params.find(
(p) => p.kind === 'file' && p.name.toLowerCase().includes('mask')
);
if (maskParam && !formData.has(maskParam.name)) {
try {
const meta = await sharp(effectiveBuffer).metadata();
const w = Math.min(meta.width || 720, 720);
const h = Math.min(meta.height || 720, 720);
const isOutpainting = endpoint.id.includes('outpaint');
const svg = isOutpainting
? `<svg width="${w}" height="${h}"><rect width="${w}" height="${h}" fill="white"/><rect x="${Math.floor(w*0.15)}" y="${Math.floor(h*0.15)}" width="${Math.floor(w*0.7)}" height="${Math.floor(h*0.7)}" fill="black"/></svg>`
: `<svg width="${w}" height="${h}"><rect width="${w}" height="${h}" fill="black"/><rect x="${Math.floor(w*0.1)}" y="${Math.floor(h*0.4)}" width="${Math.floor(w*0.8)}" height="${Math.floor(h*0.55)}" fill="white"/></svg>`;
const fallbackMask = await sharp(Buffer.from(svg)).png().toBuffer();
const maskBlob = new Blob([new Uint8Array(fallbackMask)]);
formData.append(maskParam.name, maskBlob, 'mask.png');
} catch {}
}
}
// If secondary image buffer provided (Two-Images: Face Swap, Relighting, Try-on)
@@ -170,6 +189,15 @@ export async function executeBackendTryIt(
if (endpoint.params.some((p) => p.name === 'target') && !formData.has('target')) {
formData.append('target', secBlob, options.secondaryFilename || 'reference.jpg');
}
} else {
// If endpoint requires a secondary file and none was provided, duplicate primary image as fallback
const needsSec = endpoint.params.find(
(p) => p.kind === 'file' && (p.name === 'source2' || p.name === 'target')
);
if (needsSec && !formData.has(needsSec.name)) {
const secBlob = new Blob([new Uint8Array(effectiveBuffer)]);
formData.append(needsSec.name, secBlob, filename);
}
}
// Inject Secret Key (PRD §7.11: Secrets never reach browser)