Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Tweak

Manav Rathi40dfeb5bcaf4
diff --git a/web/apps/photos/src/services/face/f-index.ts b/web/apps/photos/src/services/face/f-index.ts
index b8a058e367..210bced35c 100644
--- a/web/apps/photos/src/services/face/f-index.ts
+++ b/web/apps/photos/src/services/face/f-index.ts
@@ -118,7 +118,7 @@ const indexFaces_ = async (enteFile: EnteFile, imageBitmap: ImageBitmap) => {
const blurValues = detectBlur(alignedFacesData, mlFile.faces);
mlFile.faces.forEach((f, i) => (f.blurValue = blurValues[i]));
- const embeddings = await computeEmbedding(alignedFacesData);
+ const embeddings = await computeEmbeddings(alignedFacesData);
mlFile.faces.forEach((f, i) => (f.embedding = embeddings[i]));
convertFaceDetectionsToRelative(mlFile);
@@ -166,8 +166,7 @@ const convertToYOLOInputFloat32ChannelsFirst = (imageBitmap: ImageBitmap) => {
const requiredWidth = 640;
const requiredHeight = 640;
- const width = imageBitmap.width;
- const height = imageBitmap.height;
+ const { width, height } = imageBitmap;
// Create an OffscreenCanvas and set its size.
const offscreenCanvas = new OffscreenCanvas(width, height);
@@ -427,11 +426,13 @@ const convertToMobileFaceNetInput = (
* Laplacian blur detection.
*
* Return an array of detected blur values, one for each face in {@link faces}.
+ * The face data is taken from the slice of {@link alignedFacesData}
+ * corresponding to each face of {@link faces}.
*/
-const detectBlur = (alignedFaces: Float32Array, faces: Face[]): number[] =>
+const detectBlur = (alignedFacesData: Float32Array, faces: Face[]): number[] =>
faces.map((face, i) => {
const faceImage = grayscaleIntMatrixFromNormalized2List(
- alignedFaces,
+ alignedFacesData,
i,
mobileFaceNetFaceSize,
mobileFaceNetFaceSize,
@@ -612,7 +613,7 @@ const mobileFaceNetEmbeddingSize = 192;
*
* The model used is MobileFaceNet, running in an ONNX runtime.
*/
-const computeEmbedding = async (
+const computeEmbeddings = async (
faceData: Float32Array,
): Promise<FaceEmbedding[]> => {
const outputData = await workerBridge.faceEmbeddings(faceData);
diff --git a/web/apps/photos/src/services/face/transform-box.ts b/web/apps/photos/src/services/face/transform-box.ts
index 2a0d243b8c..b62f195488 100644
--- a/web/apps/photos/src/services/face/transform-box.ts
+++ b/web/apps/photos/src/services/face/transform-box.ts
@@ -1,6 +1,6 @@
import { Box, Point, boxFromBoundingBox } from "services/face/geom";
import { FaceDetection } from "services/face/types";
-// TODO-ML(MR): Do we need two separate Matrix libraries?
+// TODO-ML: Do we need two separate Matrix libraries?
//
// Keeping this in a separate file so that we can audit this. If these can be
// expressed using ml-matrix, then we can move the code to f-index.