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 8c5e731a3..9d3940082 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 newFaceIdToCluster = {}; final stopwatchClustering = Stopwatch()..start(); for (int i = 1; i < totalFaces; i++) {