[mob][photos] Small changes in suggestion calculation
This commit is contained in:
parent
74ae4ea74f
commit
d650bac501
1 changed files with 17 additions and 8 deletions
|
@ -784,24 +784,31 @@ class ClusterFeedbackService {
|
|||
Map<int, int>? allClusterIdsToCountMap,
|
||||
}) {
|
||||
final Map<int, List<(int, double)>> suggestions = {};
|
||||
const suggestionMax = 2000;
|
||||
int suggestionCount = 0;
|
||||
int comparisons = 0;
|
||||
final w = (kDebugMode ? EnteWatch('getSuggestions') : null)?..start();
|
||||
for (final otherClusterID in clusterAvg.keys) {
|
||||
// ignore the cluster that belong to the person or is ignored
|
||||
if (personClusters.contains(otherClusterID) ||
|
||||
ignoredClusters.contains(otherClusterID)) {
|
||||
|
||||
// ignore the clusters that belong to the person or is ignored
|
||||
Set<int> otherClusters = clusterAvg.keys.toSet().difference(personClusters);
|
||||
otherClusters = otherClusters.difference(ignoredClusters);
|
||||
|
||||
for (final otherClusterID in otherClusters) {
|
||||
final Vector? otherAvg = clusterAvg[otherClusterID];
|
||||
if (otherAvg == null) {
|
||||
_logger.warning('no avg for othercluster $otherClusterID');
|
||||
continue;
|
||||
}
|
||||
final Vector otherAvg = clusterAvg[otherClusterID]!;
|
||||
int? nearestPersonCluster;
|
||||
double? minDistance;
|
||||
for (final personCluster in personClusters) {
|
||||
if (clusterAvg[personCluster] == null) {
|
||||
_logger.info('no avg for cluster $personCluster');
|
||||
_logger.warning('no avg for personcluster $personCluster');
|
||||
continue;
|
||||
}
|
||||
final Vector avg = clusterAvg[personCluster]!;
|
||||
final distance = cosineDistanceSIMD(avg, otherAvg);
|
||||
comparisons++;
|
||||
if (distance < maxClusterDistance) {
|
||||
if (minDistance == null || distance < minDistance) {
|
||||
minDistance = distance;
|
||||
|
@ -815,11 +822,13 @@ class ClusterFeedbackService {
|
|||
.add((otherClusterID, minDistance));
|
||||
suggestionCount++;
|
||||
}
|
||||
if (suggestionCount >= 2000) {
|
||||
if (suggestionCount >= suggestionMax) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
w?.log('calculation inside calcSuggestionsMean');
|
||||
w?.log(
|
||||
'calculation inside calcSuggestionsMean for ${personClusters.length} person clusters and ${otherClusters.length} other clusters (so ${personClusters.length * otherClusters.length} combinations, $comparisons comparisons made resulted in $suggestionCount suggestions)',
|
||||
);
|
||||
|
||||
if (suggestions.isNotEmpty) {
|
||||
final List<(int, double)> suggestClusterIds = [];
|
||||
|
|
Loading…
Add table
Reference in a new issue