π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Move currently unused cluster stuff out of the way
Manav Rathifcd4459e6ddf
diff --git a/web/apps/photos/src/services/face/people.ts b/web/apps/photos/src/services/face/people.tsindex 55281768cb..0c66bcc57c 100644--- a/web/apps/photos/src/services/face/people.ts+++ b/web/apps/photos/src/services/face/people.ts@@ -1,37 +1,53 @@import log from "@/next/log";import mlIDbStorage from "services/face/db";-import { Face, Person } from "services/face/types";-import { type MLSyncContext } from "services/machineLearning/machineLearningService";+import { Person } from "services/face/types";import { clusterFaces } from "./cluster";import { saveFaceCrop } from "./f-index";import { fetchImageBitmap, getLocalFile } from "./image";-export const syncPeopleIndex = async (syncContext: MLSyncContext) => {+export const syncPeopleIndex = async () => {+ // TODO-ML(MR): Forced disable clustering. It doesn't currently work,+ // need to finalize it before we move out of beta.+ //+ // > Error: Failed to execute 'transferToImageBitmap' on+ // > 'OffscreenCanvas': ImageBitmap construction failed+ /*+ if (+ syncContext.outOfSyncFiles.length <= 0 ||+ (syncContext.nSyncedFiles === batchSize && Math.random() < 0)+ ) {+ await this.syncIndex(syncContext);+ }++ public async syncIndex(syncContext: MLSyncContext) {+ await this.getMLLibraryData(syncContext);++ // TODO-ML(MR): Ensure this doesn't run until fixed.+ await syncPeopleIndex(syncContext);++ await this.persistMLLibraryData(syncContext);+ }+const filesVersion = await mlIDbStorage.getIndexVersion("files");if (filesVersion <= (await mlIDbStorage.getIndexVersion("people"))) {return;}+ */// TODO: have faces addresable through fileId + faceId// to avoid index based addressing, which is prone to wrong results// one way could be to match nearest face within threshold in the file+ /*const allFacesMap =syncContext.allSyncedFacesMap ??(syncContext.allSyncedFacesMap = await mlIDbStorage.getAllFacesMap());- const allFaces = [...allFacesMap.values()].flat();+ */- await runFaceClustering(syncContext, allFaces);- await syncPeopleFromClusters(syncContext, allFacesMap, allFaces);-- await mlIDbStorage.setIndexVersion("people", filesVersion);-};--const runFaceClustering = async (- syncContext: MLSyncContext,- allFaces: Array<Face>,-) => {// await this.init();+ const allFacesMap = await mlIDbStorage.getAllFacesMap();+ const allFaces = [...allFacesMap.values()].flat();+if (!allFaces || allFaces.length < 50) {log.info(`Skipping clustering since number of faces (${allFaces.length}) is less than the clustering threshold (50)`,@@ -40,21 +56,15 @@ const runFaceClustering = async (}log.info("Running clustering allFaces: ", allFaces.length);- syncContext.mlLibraryData.faceClusteringResults = await clusterFaces(+ const faceClusteringResults = await clusterFaces(allFaces.map((f) => Array.from(f.embedding)),);log.info("[MLService] Got face clustering results: ",- JSON.stringify(syncContext.mlLibraryData.faceClusteringResults),+ JSON.stringify(faceClusteringResults),);-};-const syncPeopleFromClusters = async (- syncContext: MLSyncContext,- allFacesMap: Map<number, Array<Face>>,- allFaces: Array<Face>,-) => {- const clusters = syncContext.mlLibraryData.faceClusteringResults?.clusters;+ const clusters = faceClusteringResults?.clusters;if (!clusters || clusters.length < 1) {return;}@@ -95,4 +105,6 @@ const syncPeopleFromClusters = async (}await mlIDbStorage.updateFaces(allFacesMap);++ // await mlIDbStorage.setIndexVersion("people", filesVersion);};diff --git a/web/apps/photos/src/services/machineLearning/machineLearningService.ts b/web/apps/photos/src/services/machineLearning/machineLearningService.tsindex 3703f1dfde..c57866f162 100644--- a/web/apps/photos/src/services/machineLearning/machineLearningService.ts+++ b/web/apps/photos/src/services/machineLearning/machineLearningService.ts@@ -165,20 +165,6 @@ class MachineLearningService {await this.syncFiles(syncContext);}- // TODO-ML(MR): Forced disable clustering. It doesn't currently work,- // need to finalize it before we move out of beta.- //- // > Error: Failed to execute 'transferToImageBitmap' on- // > 'OffscreenCanvas': ImageBitmap construction failed- /*- if (- syncContext.outOfSyncFiles.length <= 0 ||- (syncContext.nSyncedFiles === batchSize && Math.random() < 0)- ) {- await this.syncIndex(syncContext);- }- */-const error = syncContext.error;const nOutOfSyncFiles = syncContext.outOfSyncFiles.length;return !error && nOutOfSyncFiles > 0;@@ -491,15 +477,6 @@ class MachineLearningService {private async persistMLLibraryData(syncContext: MLSyncContext) {return mlIDbStorage.putLibraryData(syncContext.mlLibraryData);}-- public async syncIndex(syncContext: MLSyncContext) {- await this.getMLLibraryData(syncContext);-- // TODO-ML(MR): Ensure this doesn't run until fixed.- await syncPeopleIndex(syncContext);-- await this.persistMLLibraryData(syncContext);- }}export default new MachineLearningService();