diff --git a/server/face-recognizer.js b/server/face-recognizer.js index 5409430..2b167d4 100644 --- a/server/face-recognizer.js +++ b/server/face-recognizer.js @@ -143,6 +143,27 @@ faceapi.nets.ssdMobilenetv1.loadFromDisk('./models') concurrency: maxConcurrency }); }); + }).then(() => { + console.log("Looking for face distances that need to be updated."); + + return photoDB.sequelize.query("SELECT id FROM faces ORDER BY id DESC LIMIT 1", { + type: photoDB.sequelize.QueryTypes.SELECT + } + }).then((results) => { + if (!results.length) { + console.log("No faces exist yet to generate distances."); + return; + } + const maxId = results[0].id; + return photoDB.sequelize.query("SELECT id FROM faces WHERE lastComparedId<:maxId OR lastComparedId IS NULL", { + replacements: { + maxId: maxId + }, + type: photoDB.sequelize.QueryTypes.SELECT + }).then((results) => { + console.log(`${results.length} faces need to be updated.`); + }); + }); }).then(() => { console.log("Face detection scanning completed."); }).catch((error) => {