Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][face] Fix handling of case when noCluster id is assigned

Neeraj Gupta412e93c9fa96
diff --git a/mobile/lib/services/machine_learning/face_ml/face_clustering/linear_clustering_service.dart b/mobile/lib/services/machine_learning/face_ml/face_clustering/linear_clustering_service.dart
index 8c5e731a36..9d3940082b 100644
--- a/mobile/lib/services/machine_learning/face_ml/face_clustering/linear_clustering_service.dart
+++ b/mobile/lib/services/machine_learning/face_ml/face_clustering/linear_clustering_service.dart
@@ -240,6 +240,7 @@ class FaceClustering {
isRunning = false;
return faceIdToCluster;
} catch (e, stackTrace) {
+ _logger.severe('Error while running clustering', e, stackTrace);
isRunning = false;
rethrow;
}
@@ -355,8 +356,7 @@ class FaceClustering {
// Make sure the first face has a clusterId
final int totalFaces = sortedFaceInfos.length;
- // set current epoch time as clusterID
- int clusterID = DateTime.now().microsecondsSinceEpoch;
+
if (sortedFaceInfos.isEmpty) {
return {};
}
@@ -365,6 +365,13 @@ class FaceClustering {
log(
"[ClusterIsolate] ${DateTime.now()} Processing $totalFaces faces",
);
+ // set current epoch time as clusterID
+ int clusterID = DateTime.now().microsecondsSinceEpoch;
+ if (facesWithClusterID.isEmpty) {
+ // assign a clusterID to the first face
+ sortedFaceInfos[0].clusterId = clusterID;
+ clusterID++;
+ }
final Map<String, int> newFaceIdToCluster = {};
final stopwatchClustering = Stopwatch()..start();
for (int i = 1; i < totalFaces; i++) {