Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob] Better face clustering logging

laurenspriemc58a8dc7733a
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 fd4d6f6ae5..9baf072c80 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
@@ -104,10 +104,12 @@ class FaceClustering {
final fileIDToCreationTime =
args['fileIDToCreationTime'] as Map<int, int>?;
final distanceThreshold = args['distanceThreshold'] as double;
+ final offset = args['offset'] as int?;
final result = FaceClustering._runLinearClustering(
input,
fileIDToCreationTime: fileIDToCreationTime,
distanceThreshold: distanceThreshold,
+ offset: offset,
);
sendPort.send(result);
break;
@@ -201,6 +203,7 @@ class FaceClustering {
Map<String, (int?, Uint8List)> input, {
Map<int, int>? fileIDToCreationTime,
double distanceThreshold = kRecommendedDistanceThreshold,
+ int? offset,
}) async {
if (input.isEmpty) {
_logger.warning(
@@ -229,6 +232,7 @@ class FaceClustering {
'input': input,
'fileIDToCreationTime': fileIDToCreationTime,
'distanceThreshold': distanceThreshold,
+ 'offset': offset,
}
),
);
@@ -299,6 +303,7 @@ class FaceClustering {
Map<String, (int?, Uint8List)> x, {
Map<int, int>? fileIDToCreationTime,
double distanceThreshold = kRecommendedDistanceThreshold,
+ int? offset,
}) {
log(
"[ClusterIsolate] ${DateTime.now()} Copied to isolate ${x.length} faces",
@@ -363,7 +368,7 @@ class FaceClustering {
// Start actual clustering
log(
- "[ClusterIsolate] ${DateTime.now()} Processing $totalFaces faces",
+ "[ClusterIsolate] ${DateTime.now()} Processing $totalFaces faces in total in this round ${offset != null ? "on top of ${offset + facesWithClusterID.length} earlier processed faces" : ""}",
);
// set current epoch time as clusterID
int clusterID = DateTime.now().microsecondsSinceEpoch;
@@ -384,7 +389,7 @@ class FaceClustering {
int closestIdx = -1;
double closestDistance = double.infinity;
if (i % 250 == 0) {
- log("[ClusterIsolate] ${DateTime.now()} Processing $i faces");
+ log("[ClusterIsolate] ${DateTime.now()} Processed ${offset != null ? i + offset : i} faces");
}
for (int j = i - 1; j >= 0; j--) {
late double distance;
diff --git a/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart b/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart
index ab35f19554..dcbb26ba34 100644
--- a/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart
+++ b/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart
@@ -380,6 +380,7 @@ class FaceMlService {
const int batchSize = 20000;
const int offsetIncrement = 7500;
int offset = 0;
+ int bucket = 1;
while (true) {
final faceIdToEmbeddingBucket =
@@ -402,6 +403,7 @@ class FaceMlService {
final faceIdToCluster = await FaceClustering.instance.predictLinear(
faceIdToEmbeddingBucket,
fileIDToCreationTime: fileIDToCreationTime,
+ offset: offset,
);
if (faceIdToCluster == null) {
_logger.warning("faceIdToCluster is null");
@@ -409,7 +411,11 @@ class FaceMlService {
}
await FaceMLDataDB.instance.updateClusterIdToFaceId(faceIdToCluster);
+ _logger.info(
+ 'Done with clustering ${offset + faceIdToEmbeddingBucket.length} embeddings (${(100 * (offset + faceIdToEmbeddingBucket.length) / totalFaces).toStringAsFixed(0)}%) in bucket $bucket, offset: $offset',
+ );
offset += offsetIncrement;
+ bucket++;
}
} else {
final int totalFaces = await FaceMLDataDB.instance