Skip to content

armgit / ente

Public Imported from GitHub
0

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

Closer

Manav Rathi2b3b84de0f3d
diff --git a/web/apps/photos/src/services/face/f-index.ts b/web/apps/photos/src/services/face/f-index.ts
index 450e72841c..690f383b22 100644
--- a/web/apps/photos/src/services/face/f-index.ts
+++ b/web/apps/photos/src/services/face/f-index.ts
@@ -22,7 +22,7 @@ import {
pixelRGBBilinear,
warpAffineFloat32List,
} from "./image";
-import type { Box, Dimensions, Point } from "./types";
+import type { Box, Dimensions, Face, Point } from "./types";
import type { MlFileData } from "./types-old";
/**
@@ -126,7 +126,7 @@ const indexFaces_ = async (
const indexFacesInBitmap = async (
fileID: number,
imageBitmap: ImageBitmap,
-): Promise<MlFileData["faceEmbedding"]["faces"]> => {
+): Promise<Face[]> => {
const { width, height } = imageBitmap;
const imageBox = { width, height };
@@ -166,22 +166,13 @@ const indexFacesInBitmap = async (
partialResult.map((f) => f.detection),
);
- const faces = [];
-
- for (let i = 0; i < partialResult.length; i++) {
- const { faceID, detection, score } = partialResult[i];
- const blur = blurs[i];
- const embedding = embeddings[i];
- faces.push({
- faceID,
- detection: relativeDetection(detection, imageBox),
- score,
- blur,
- embedding,
- });
- }
-
- return faces;
+ return partialResult.map(({ faceID, detection, score }, i) => ({
+ faceID,
+ detection: relativeDetection(detection, imageBox),
+ score,
+ blur: blurs[i],
+ embedding: Array.from(embeddings[i]),
+ }));
};
/**
diff --git a/web/apps/photos/src/services/face/remote.ts b/web/apps/photos/src/services/face/remote.ts
index c6b3c84491..b1ce10366d 100644
--- a/web/apps/photos/src/services/face/remote.ts
+++ b/web/apps/photos/src/services/face/remote.ts
@@ -3,7 +3,7 @@ import ComlinkCryptoWorker from "@ente/shared/crypto";
import { putEmbedding } from "services/embeddingService";
import type { EnteFile } from "types/file";
import type { Point } from "./types";
-import type { Face, FaceDetection, MlFileData } from "./types-old";
+import type { MlFileData } from "./types-old";
export const putFaceEmbedding = async (
enteFile: EnteFile,
@@ -117,24 +117,24 @@ function LocalFileMlDataToServerFileMl(
const faces: ServerFace[] = [];
for (let i = 0; i < localFileMlData.faceEmbedding.faces.length; i++) {
- const face: Face = localFileMlData.faceEmbedding.faces[i];
+ const face = localFileMlData.faceEmbedding.faces[i];
const faceID = face.faceID;
const embedding = face.embedding;
const score = face.score;
const blur = face.blur;
- const detection: FaceDetection = face.detection;
+ const detection = face.detection;
const box = detection.box;
const landmarks = detection.landmarks;
- const newBox = new ServerFaceBox(box.x, box.y, box.width, box.height);
-
- const newFaceObject = new ServerFace(
- faceID,
- Array.from(embedding),
- new ServerDetection(newBox, landmarks),
- score,
- blur,
+
+ faces.push(
+ new ServerFace(
+ faceID,
+ Array.from(embedding),
+ new ServerDetection(box, landmarks),
+ score,
+ blur,
+ ),
);
- faces.push(newFaceObject);
}
const faceEmbedding = new ServerFaceEmbedding(
faces,