Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob] clustering make it difficult for good faces to link to bad faces

laurensprieme3fd8369013d
diff --git a/mobile/lib/services/machine_learning/face_ml/face_clustering/face_clustering_service.dart b/mobile/lib/services/machine_learning/face_ml/face_clustering/face_clustering_service.dart
index d2445c99e9..a71da45bce 100644
--- a/mobile/lib/services/machine_learning/face_ml/face_clustering/face_clustering_service.dart
+++ b/mobile/lib/services/machine_learning/face_ml/face_clustering/face_clustering_service.dart
@@ -19,6 +19,7 @@ class FaceInfo {
final String faceID;
final double? faceScore;
final double? blurValue;
+ final bool? badFace;
final List<double>? embedding;
final Vector? vEmbedding;
int? clusterId;
@@ -29,6 +30,7 @@ class FaceInfo {
required this.faceID,
this.faceScore,
this.blurValue,
+ this.badFace,
this.embedding,
this.vEmbedding,
this.clusterId,
@@ -312,6 +314,8 @@ class FaceClusteringService {
faceID: face.faceID,
faceScore: face.faceScore,
blurValue: face.blurValue,
+ badFace: face.faceScore < kMinHighQualityFaceScore ||
+ face.blurValue < kLaplacianSoftThreshold,
vEmbedding: Vector.fromList(
EVector.fromBuffer(face.embeddingBytes).values,
dtype: DType.float32,
@@ -388,12 +392,10 @@ class FaceClusteringService {
double closestDistance = double.infinity;
late double thresholdValue;
if (useDynamicThreshold) {
- final bool badFace =
- (sortedFaceInfos[i].faceScore! < kMinHighQualityFaceScore ||
- sortedFaceInfos[i].blurValue! < kLaplacianSoftThreshold);
- thresholdValue =
- badFace ? conservativeDistanceThreshold : distanceThreshold;
- if (badFace) dynamicThresholdCount++;
+ thresholdValue = sortedFaceInfos[i].badFace!
+ ? conservativeDistanceThreshold
+ : distanceThreshold;
+ if (sortedFaceInfos[i].badFace!) dynamicThresholdCount++;
} else {
thresholdValue = distanceThreshold;
}
@@ -414,6 +416,10 @@ class FaceClusteringService {
);
}
if (distance < closestDistance) {
+ if (sortedFaceInfos[j].badFace! &&
+ distance > conservativeDistanceThreshold) {
+ continue;
+ }
closestDistance = distance;
closestIdx = j;
// if (distance < distanceThreshold) {