This commit is contained in:
Manav Rathi 2024-05-18 16:56:18 +05:30
parent a2e7231c37
commit c557e4a7a5
No known key found for this signature in database

View file

@ -105,7 +105,21 @@ const indexFaces_ = async (enteFile: EnteFile, imageBitmap: ImageBitmap) => {
const { width, height } = imageBitmap;
fileContext.newMlFile.imageDimensions = { width, height };
await syncFileFaceDetections(fileContext);
const faceDetections = await detectFaces(imageBitmap);
const detectedFaces = faceDetections?.map((detection) => {
return {
fileId: fileContext.enteFile.id,
detection,
} as DetectedFace;
});
newMlFile.faces = detectedFaces?.map((detectedFace) => ({
...detectedFace,
id: makeFaceID(detectedFace, newMlFile.imageDimensions),
}));
// TODO-ML(MR): reenable faces filtering based on width
// ?.filter((f) =>
// f.box.width > syncContext.config.faceDetection.minFaceSize
// );
if (newMlFile.faces && newMlFile.faces.length > 0) {
await syncFileFaceCrops(fileContext);
@ -121,27 +135,6 @@ const indexFaces_ = async (enteFile: EnteFile, imageBitmap: ImageBitmap) => {
return newMlFile;
};
const syncFileFaceDetections = async (fileContext: MLSyncFileContext) => {
const { newMlFile } = fileContext;
const imageBitmap = fileContext.imageBitmap;
const faceDetections = await detectFaces(imageBitmap);
// TODO-ML(MR): reenable faces filtering based on width
const detectedFaces = faceDetections?.map((detection) => {
return {
fileId: fileContext.enteFile.id,
detection,
} as DetectedFace;
});
newMlFile.faces = detectedFaces?.map((detectedFace) => ({
...detectedFace,
id: makeFaceID(detectedFace, newMlFile.imageDimensions),
}));
// ?.filter((f) =>
// f.box.width > syncContext.config.faceDetection.minFaceSize
// );
log.info("[MLService] Detected Faces: ", newMlFile.faces?.length);
};
/**
* Detect faces in the given {@link imageBitmap}.
*