Added support for new faceai parameters
All checks were successful
Publish FaceAI Container / publish (push) Successful in 9m39s

This commit is contained in:
MaddoScientisto 2026-05-09 14:46:44 +02:00
commit a026fec62b
12 changed files with 152 additions and 13 deletions

View file

@ -1,5 +1,24 @@
import path from 'node:path';
function readOptionalNumberEnv(name) {
const raw = process.env[name];
if (raw === undefined || raw === '') {
return null;
}
const value = Number(raw);
if (Number.isNaN(value)) {
throw new Error(`${name} must be a number when set`);
}
return value;
}
const matcherTolerance = readOptionalNumberEnv('FACEAI_MATCHER_TOLERANCE');
if (matcherTolerance !== null && (matcherTolerance < 0.35 || matcherTolerance > 0.75)) {
throw new Error('FACEAI_MATCHER_TOLERANCE must be between 0.35 and 0.75');
}
export const config = {
redisUrl: process.env.FACEAI_REDIS_URL || 'redis://redis:6379',
queueName: process.env.FACEAI_QUEUE_NAME || 'faceai-searches',
@ -9,6 +28,7 @@ export const config = {
logRoot: process.env.FACEAI_LOG_ROOT || path.join(process.env.FACEAI_RUNTIME_ROOT || '/data/runtime', 'logs'),
pklRoot: process.env.FACEAI_PKL_ROOT || '/data/pkl',
matcherBinary: process.env.FACEAI_MATCHER_BINARY || '/app/bin/face_matcher',
matcherTolerance,
processorHeartbeatIntervalMs: Number(process.env.FACEAI_PROCESSOR_HEARTBEAT_INTERVAL_MS || 5 * 1000),
processorHeartbeatTtlSeconds: Number(process.env.FACEAI_PROCESSOR_HEARTBEAT_TTL_SECONDS || 60),
searchTtlSeconds: Number(process.env.FACEAI_SEARCH_TTL_SECONDS || 24 * 60 * 60),

View file

@ -19,17 +19,23 @@ export async function resolvePklPath({ raceId, raceStorage, pklRoot }) {
return availability.pklPath;
}
export async function runFaceMatcher({ matcherBinary, selfiePath, pklPath, csvPath, logPath, timeoutMs }) {
export async function runFaceMatcher({ matcherBinary, matcherTolerance, selfiePath, pklPath, csvPath, logPath, timeoutMs }) {
await fs.mkdir(path.dirname(csvPath), { recursive: true });
await fs.mkdir(path.dirname(logPath), { recursive: true });
return new Promise((resolve, reject) => {
const child = spawn(matcherBinary, [
const matcherArgs = [
'--image', selfiePath,
'--encodings', pklPath,
'--out', csvPath,
'--log', logPath
], {
];
if (matcherTolerance !== null && matcherTolerance !== undefined) {
matcherArgs.push('--tollerance', String(matcherTolerance));
}
const child = spawn(matcherBinary, matcherArgs, {
stdio: 'ignore'
});

View file

@ -34,6 +34,9 @@ async function ensureMatcherBinaryAvailable() {
}
console.log(`FaceAI processor configured matcher binary: ${config.matcherBinary}`);
if (config.matcherTolerance !== null) {
console.log(`FaceAI processor configured matcher tolerance: ${config.matcherTolerance}`);
}
async function publishProcessorHeartbeat() {
try {
@ -138,6 +141,7 @@ async function processJob(job) {
await appendSearchLog(searchLogPath, 'Running matcher', {
matcherBinary: config.matcherBinary,
matcherTolerance: config.matcherTolerance,
csvPath,
matcherLogPath: logPath,
timeoutMs: config.workerTimeoutMs
@ -146,6 +150,7 @@ async function processJob(job) {
try {
await runFaceMatcher({
matcherBinary: config.matcherBinary,
matcherTolerance: config.matcherTolerance,
selfiePath: search.selfiePath,
pklPath,
csvPath,