π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Dont recluster rejected face to cluster mapping
laurenspriem5d99a7c75707
diff --git a/mobile/lib/services/machine_learning/face_ml/face_clustering/face_clustering_service.dart b/mobile/lib/services/machine_learning/face_ml/face_clustering/face_clustering_service.dartindex ebb16f2252..f2c53771cd 100644--- a/mobile/lib/services/machine_learning/face_ml/face_clustering/face_clustering_service.dart+++ b/mobile/lib/services/machine_learning/face_ml/face_clustering/face_clustering_service.dart@@ -22,6 +22,7 @@ class FaceInfo {final bool? badFace;final Vector? vEmbedding;String? clusterId;+ final List<String>? rejectedClusterIds;String? closestFaceId;int? closestDist;int? fileCreationTime;@@ -32,6 +33,7 @@ class FaceInfo {this.badFace,this.vEmbedding,this.clusterId,+ this.rejectedClusterIds,this.fileCreationTime,});}@@ -328,6 +330,7 @@ ClusteringResult runLinearClustering(Map args) {dtype: DType.float32,),clusterId: face.clusterId,+ rejectedClusterIds: face.rejectedClusterIds,fileCreationTime:fileIDToCreationTime?[getFileIdFromFaceId(face.faceID)],),@@ -372,7 +375,6 @@ ClusteringResult runLinearClustering(Map args) {_logger.info("[ClusterIsolate] ${DateTime.now()} Processing $totalFaces faces ($newToClusterCount new, $alreadyClusteredCount already done) in total in this round ${offset != null ? "on top of ${offset + facesWithClusterID.length} earlier processed faces" : ""}",);- // set current epoch time as clusterIDString clusterID = newClusterID();if (facesWithClusterID.isEmpty) {// assign a clusterID to the first face@@ -398,6 +400,7 @@ ClusteringResult runLinearClustering(Map args) {} else {thresholdValue = distanceThreshold;}+ final bool faceHasBeenRejectedBefore = sortedFaceInfos[i].rejectedClusterIds != null;if (i % 250 == 0) {_logger.info("Processed ${offset != null ? i + offset : i} faces");}@@ -410,6 +413,13 @@ ClusteringResult runLinearClustering(Map args) {distance > conservativeDistanceThreshold) {continue;}+ if (faceHasBeenRejectedBefore &&+ sortedFaceInfos[j].clusterId != null &&+ sortedFaceInfos[i].rejectedClusterIds!.contains(+ sortedFaceInfos[j].clusterId!,+ )) {+ continue;+ }closestDistance = distance;closestIdx = j;}diff --git a/mobile/lib/services/machine_learning/face_ml/face_clustering/face_db_info_for_clustering.dart b/mobile/lib/services/machine_learning/face_ml/face_clustering/face_db_info_for_clustering.dartindex 1822d3fb55..6726761415 100644--- a/mobile/lib/services/machine_learning/face_ml/face_clustering/face_db_info_for_clustering.dart+++ b/mobile/lib/services/machine_learning/face_ml/face_clustering/face_db_info_for_clustering.dart@@ -3,6 +3,7 @@ import "dart:typed_data" show Uint8List;class FaceDbInfoForClustering {final String faceID;String? clusterId;+ List<String>? rejectedClusterIds;final Uint8List embeddingBytes;final double faceScore;final double blurValue;diff --git a/mobile/lib/services/machine_learning/ml_service.dart b/mobile/lib/services/machine_learning/ml_service.dartindex a9f300d74c..929730b3a6 100644--- a/mobile/lib/services/machine_learning/ml_service.dart+++ b/mobile/lib/services/machine_learning/ml_service.dart@@ -250,6 +250,19 @@ class MLService {_logger.info('Pulling remote feedback before actually clustering');await PersonService.instance.fetchRemoteClusterFeedback();+ final persons = await PersonService.instance.getPersons();+ final faceIdNotToCluster = <String, List<String>>{};+ for (final person in persons) {+ if (person.data.rejectedFaceIDs != null &&+ person.data.rejectedFaceIDs!.isNotEmpty) {+ final personClusters = person.data.assigned?.map((e) => e.id).toList();+ if (personClusters != null) {+ for (final faceID in person.data.rejectedFaceIDs!) {+ faceIdNotToCluster[faceID] = personClusters;+ }+ }+ }+ }try {_showClusteringIsHappening = true;@@ -271,6 +284,9 @@ class MLService {if (!fileIDToCreationTime.containsKey(faceInfo.fileID)) {missingFileIDs.add(faceInfo.fileID);} else {+ if (faceIdNotToCluster.containsKey(faceInfo.faceID)) {+ faceInfo.rejectedClusterIds = faceIdNotToCluster[faceInfo.faceID];+ }allFaceInfoForClustering.add(faceInfo);}}