[mob][photos] Fix regression in suggestion calculation

This commit is contained in:
laurenspriem 2024-05-02 11:18:06 +05:30
parent 689833d8aa
commit 74ae4ea74f

View file

@ -481,46 +481,46 @@ class ClusterFeedbackService {
late Map<int, Vector> clusterAvgBigClusters; late Map<int, Vector> clusterAvgBigClusters;
final List<(int, double)> suggestionsMean = []; final List<(int, double)> suggestionsMean = [];
for (final minimumSize in checkSizes.toSet()) { for (final minimumSize in checkSizes.toSet()) {
// if (smallestPersonClusterSize >= minimumSize) { if (smallestPersonClusterSize >= minimumSize) {
clusterAvgBigClusters = await _getUpdateClusterAvg( clusterAvgBigClusters = await _getUpdateClusterAvg(
allClusterIdsToCountMap, allClusterIdsToCountMap,
ignoredClusters, ignoredClusters,
minClusterSize: minimumSize, minClusterSize: minimumSize,
); );
w?.log( w?.log(
'Calculate avg for ${clusterAvgBigClusters.length} clusters of min size $minimumSize', 'Calculate avg for ${clusterAvgBigClusters.length} clusters of min size $minimumSize',
); );
final List<(int, double)> suggestionsMeanBigClusters = final List<(int, double)> suggestionsMeanBigClusters =
_calcSuggestionsMean( _calcSuggestionsMean(
clusterAvgBigClusters, clusterAvgBigClusters,
personClusters, personClusters,
ignoredClusters, ignoredClusters,
goodMeanDistance, goodMeanDistance,
); );
w?.log( w?.log(
'Calculate suggestions using mean for ${clusterAvgBigClusters.length} clusters of min size $minimumSize', 'Calculate suggestions using mean for ${clusterAvgBigClusters.length} clusters of min size $minimumSize',
); );
for (final suggestion in suggestionsMeanBigClusters) { for (final suggestion in suggestionsMeanBigClusters) {
// Skip suggestions that have a high overlap with the person's files // Skip suggestions that have a high overlap with the person's files
final suggestionSet = allClusterIdToFaceIDs[suggestion.$1]! final suggestionSet = allClusterIdToFaceIDs[suggestion.$1]!
.map((faceID) => getFileIdFromFaceId(faceID)) .map((faceID) => getFileIdFromFaceId(faceID))
.toSet(); .toSet();
final overlap = personFileIDs.intersection(suggestionSet); final overlap = personFileIDs.intersection(suggestionSet);
if (overlap.isNotEmpty && if (overlap.isNotEmpty &&
((overlap.length / suggestionSet.length) > 0.5)) { ((overlap.length / suggestionSet.length) > 0.5)) {
await FaceMLDataDB.instance.captureNotPersonFeedback( await FaceMLDataDB.instance.captureNotPersonFeedback(
personID: p.remoteID, personID: p.remoteID,
clusterID: suggestion.$1, clusterID: suggestion.$1,
); );
continue; 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(); w?.reset();