Skip to content

armgit / ente

Public Imported from GitHub
0

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

Inline

Manav Rathi095e8c7091da
diff --git a/web/apps/photos/src/services/machineLearning/faceService.ts b/web/apps/photos/src/services/machineLearning/faceService.ts
index 34b2ef669c..93e2c0a0a5 100644
--- a/web/apps/photos/src/services/machineLearning/faceService.ts
+++ b/web/apps/photos/src/services/machineLearning/faceService.ts
@@ -10,12 +10,12 @@ import {
type Versioned,
} from "services/ml/types";
import { imageBitmapToBlob, warpAffineFloat32List } from "utils/image";
+import { DEFAULT_ML_SYNC_CONFIG } from "./machineLearningService";
import ReaderService, {
fetchImageBitmap,
getFaceId,
getLocalFile,
} from "./readerService";
-import { DEFAULT_ML_SYNC_CONFIG } from "./machineLearningService";
class FaceService {
async syncFileFaceDetections(
@@ -44,10 +44,7 @@ class FaceService {
newMlFile.faceDetectionMethod = syncContext.faceDetectionService.method;
fileContext.newDetection = true;
- const imageBitmap = await ReaderService.getImageBitmap(
- syncContext,
- fileContext,
- );
+ const imageBitmap = await ReaderService.getImageBitmap(fileContext);
const timerId = `faceDetection-${fileContext.enteFile.id}`;
console.time(timerId);
const faceDetections =
@@ -93,10 +90,7 @@ class FaceService {
return;
}
- const imageBitmap = await ReaderService.getImageBitmap(
- syncContext,
- fileContext,
- );
+ const imageBitmap = await ReaderService.getImageBitmap(fileContext);
newMlFile.faceCropMethod = syncContext.faceCropService.method;
for (const face of newMlFile.faces) {
@@ -128,7 +122,7 @@ class FaceService {
fileContext.newAlignment = true;
const imageBitmap =
fileContext.imageBitmap ||
- (await ReaderService.getImageBitmap(syncContext, fileContext));
+ (await ReaderService.getImageBitmap(fileContext));
// Execute the face alignment calculations
for (const face of newMlFile.faces) {
@@ -179,7 +173,7 @@ class FaceService {
newMlFile.faceEmbeddingMethod = syncContext.faceEmbeddingService.method;
// TODO: when not storing face crops, image will be needed to extract faces
// fileContext.imageBitmap ||
- // (await this.getImageBitmap(syncContext, fileContext));
+ // (await this.getImageBitmap(fileContext));
const embeddings =
await syncContext.faceEmbeddingService.getFaceEmbeddings(
diff --git a/web/apps/photos/src/services/machineLearning/machineLearningService.ts b/web/apps/photos/src/services/machineLearning/machineLearningService.ts
index 8f12d60147..2ebd14efeb 100644
--- a/web/apps/photos/src/services/machineLearning/machineLearningService.ts
+++ b/web/apps/photos/src/services/machineLearning/machineLearningService.ts
@@ -181,15 +181,6 @@ export class MLFactory {
throw Error("Unknon clustering method: " + method);
}
-
- public static getMLSyncContext(
- token: string,
- userID: number,
- config: MLSyncConfig,
- shouldUpdateMLVersion: boolean = true,
- ) {
- return new LocalMLSyncContext(token, userID, shouldUpdateMLVersion);
- }
}
export class LocalMLSyncContext implements MLSyncContext {
@@ -465,17 +456,9 @@ class MachineLearningService {
if (!this.syncContext) {
log.info("Creating syncContext");
- const mlSyncConfig = DEFAULT_ML_SYNC_CONFIG;
// TODO-ML(MR): Keep as promise for now.
this.syncContext = new Promise((resolve) => {
- resolve(
- MLFactory.getMLSyncContext(
- token,
- userID,
- mlSyncConfig,
- true,
- ),
- );
+ resolve(new LocalMLSyncContext(token, userID, true));
});
} else {
log.info("reusing existing syncContext");
@@ -488,15 +471,7 @@ class MachineLearningService {
log.info("Creating localSyncContext");
// TODO-ML(MR):
this.localSyncContext = new Promise((resolve) => {
- const mlSyncConfig = DEFAULT_ML_SYNC_CONFIG;
- resolve(
- MLFactory.getMLSyncContext(
- token,
- userID,
- mlSyncConfig,
- false,
- ),
- );
+ resolve(new LocalMLSyncContext(token, userID, false));
});
} else {
log.info("reusing existing localSyncContext");
@@ -610,7 +585,7 @@ class MachineLearningService {
}
try {
- await ReaderService.getImageBitmap(syncContext, fileContext);
+ await ReaderService.getImageBitmap(fileContext);
await Promise.all([
this.syncFileAnalyzeFaces(syncContext, fileContext),
]);
diff --git a/web/apps/photos/src/services/machineLearning/readerService.ts b/web/apps/photos/src/services/machineLearning/readerService.ts
index e6b95d2534..98052edfa4 100644
--- a/web/apps/photos/src/services/machineLearning/readerService.ts
+++ b/web/apps/photos/src/services/machineLearning/readerService.ts
@@ -4,21 +4,14 @@ import log from "@/next/log";
import DownloadManager from "services/download";
import { getLocalFiles } from "services/fileService";
import { Dimensions } from "services/ml/geom";
-import {
- DetectedFace,
- MLSyncContext,
- MLSyncFileContext,
-} from "services/ml/types";
+import { DetectedFace, MLSyncFileContext } from "services/ml/types";
import { EnteFile } from "types/file";
import { getRenderableImage } from "utils/file";
import { clamp } from "utils/image";
import { DEFAULT_ML_SYNC_CONFIG } from "./machineLearningService";
class ReaderService {
- async getImageBitmap(
- syncContext: MLSyncContext,
- fileContext: MLSyncFileContext,
- ) {
+ async getImageBitmap(fileContext: MLSyncFileContext) {
try {
if (fileContext.imageBitmap) {
return fileContext.imageBitmap;
diff --git a/web/apps/photos/src/services/ml/types.ts b/web/apps/photos/src/services/ml/types.ts
index 422cf9d4aa..f7382d3da7 100644
--- a/web/apps/photos/src/services/ml/types.ts
+++ b/web/apps/photos/src/services/ml/types.ts
@@ -208,7 +208,6 @@ export interface MLSearchConfig {
export interface MLSyncContext {
token: string;
userID: number;
- config: MLSyncConfig;
shouldUpdateMLVersion: boolean;
faceDetectionService: FaceDetectionService;