From 74ae4ea74f53d2255462cb397bf96069549e1b5e Mon Sep 17 00:00:00 2001 From: laurenspriem Date: Thu, 2 May 2024 11:18:06 +0530 Subject: [PATCH] [mob][photos] Fix regression in suggestion calculation --- .../face_ml/feedback/cluster_feedback.dart | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart b/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart index 95b3f2b081..2c57252c21 100644 --- a/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart +++ b/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart @@ -481,46 +481,46 @@ class ClusterFeedbackService { late Map clusterAvgBigClusters; final List<(int, double)> suggestionsMean = []; for (final minimumSize in checkSizes.toSet()) { - // if (smallestPersonClusterSize >= minimumSize) { - clusterAvgBigClusters = await _getUpdateClusterAvg( - allClusterIdsToCountMap, - ignoredClusters, - minClusterSize: minimumSize, - ); - w?.log( - 'Calculate avg for ${clusterAvgBigClusters.length} clusters of min size $minimumSize', - ); - final List<(int, double)> suggestionsMeanBigClusters = - _calcSuggestionsMean( - clusterAvgBigClusters, - personClusters, - ignoredClusters, - goodMeanDistance, - ); - w?.log( - 'Calculate suggestions using mean for ${clusterAvgBigClusters.length} clusters of min size $minimumSize', - ); - for (final suggestion in suggestionsMeanBigClusters) { - // Skip suggestions that have a high overlap with the person's files - final suggestionSet = allClusterIdToFaceIDs[suggestion.$1]! - .map((faceID) => getFileIdFromFaceId(faceID)) - .toSet(); - final overlap = personFileIDs.intersection(suggestionSet); - if (overlap.isNotEmpty && - ((overlap.length / suggestionSet.length) > 0.5)) { - await FaceMLDataDB.instance.captureNotPersonFeedback( - personID: p.remoteID, - clusterID: suggestion.$1, - ); - continue; + if (smallestPersonClusterSize >= minimumSize) { + clusterAvgBigClusters = await _getUpdateClusterAvg( + allClusterIdsToCountMap, + ignoredClusters, + minClusterSize: minimumSize, + ); + w?.log( + 'Calculate avg for ${clusterAvgBigClusters.length} clusters of min size $minimumSize', + ); + final List<(int, double)> suggestionsMeanBigClusters = + _calcSuggestionsMean( + clusterAvgBigClusters, + personClusters, + ignoredClusters, + goodMeanDistance, + ); + w?.log( + 'Calculate suggestions using mean for ${clusterAvgBigClusters.length} clusters of min size $minimumSize', + ); + for (final suggestion in suggestionsMeanBigClusters) { + // Skip suggestions that have a high overlap with the person's files + final suggestionSet = allClusterIdToFaceIDs[suggestion.$1]! + .map((faceID) => getFileIdFromFaceId(faceID)) + .toSet(); + final overlap = personFileIDs.intersection(suggestionSet); + if (overlap.isNotEmpty && + ((overlap.length / suggestionSet.length) > 0.5)) { + await FaceMLDataDB.instance.captureNotPersonFeedback( + personID: p.remoteID, + clusterID: suggestion.$1, + ); + continue; + } + suggestionsMean.add(suggestion); + } + if (suggestionsMean.isNotEmpty) { + return suggestionsMean + .map((e) => (e.$1, e.$2, true)) + .toList(growable: false); } - suggestionsMean.add(suggestion); - } - if (suggestionsMean.isNotEmpty) { - return suggestionsMean - .map((e) => (e.$1, e.$2, true)) - .toList(growable: false); - // } } } w?.reset();