π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Better use of constants
laurenspriema443ac168033
diff --git a/mobile/lib/face/db.dart b/mobile/lib/face/db.dartindex c8b4f75f71..bc4b15885b 100644--- a/mobile/lib/face/db.dart+++ b/mobile/lib/face/db.dart@@ -154,7 +154,7 @@ class FaceMLDataDB {final Map<int, int> result = {};final db = await instance.database;final List<Map<String, dynamic>> maps = await db.rawQuery(- 'SELECT $fileIDColumn, COUNT(*) as count FROM $facesTable where $faceScore > 0.8 GROUP BY $fileIDColumn',+ 'SELECT $fileIDColumn, COUNT(*) as count FROM $facesTable where $faceScore > $kMinFaceDetectionScore GROUP BY $fileIDColumn',);for (final map in maps) {@@ -197,7 +197,7 @@ class FaceMLDataDB {final clusterIDs =cluterRows.map((e) => e[cluserIDColumn] as int).toList();final List<Map<String, dynamic>> faceMaps = await db.rawQuery(- 'SELECT * FROM $facesTable where $faceClusterId IN (${clusterIDs.join(",")}) AND $fileIDColumn in (${fileId.join(",")}) AND $faceScore > 0.8 ORDER BY $faceScore DESC',+ 'SELECT * FROM $facesTable where $faceClusterId IN (${clusterIDs.join(",")}) AND $fileIDColumn in (${fileId.join(",")}) AND $faceScore > $kMinHighQualityFaceScore ORDER BY $faceScore DESC',);if (faceMaps.isNotEmpty) {if (avatarFileId != null) {@@ -341,7 +341,7 @@ class FaceMLDataDB {////// Only selects faces with score greater than [minScore] and blur score greater than [minClarity]Future<Map<String, (int?, Uint8List)>> getFaceEmbeddingMap({- double minScore = kMinFaceScore,+ double minScore = kMinHighQualityFaceScore,int minClarity = kLaplacianThreshold,int maxRows = 20000,}) async {@@ -398,7 +398,7 @@ class FaceMLDataDB {facesTable,columns: [faceIDColumn, faceEmbeddingBlob],where:- '$faceScore > 0.8 AND $faceBlur > $kLaplacianThreshold AND $fileIDColumn IN (${fileIDs.join(",")})',+ '$faceScore > $kMinHighQualityFaceScore AND $faceBlur > $kLaplacianThreshold AND $fileIDColumn IN (${fileIDs.join(",")})',limit: batchSize,offset: offset,orderBy: '$faceIDColumn DESC',diff --git a/mobile/lib/face/model/face.dart b/mobile/lib/face/model/face.dartindex c29c03ae11..af151c2ecf 100644--- a/mobile/lib/face/model/face.dart+++ b/mobile/lib/face/model/face.dart@@ -11,7 +11,7 @@ class Face {bool get isBlurry => blur < kLaplacianThreshold;- bool get hasHighScore => score > kMinFaceScore;+ bool get hasHighScore => score > kMinHighQualityFaceScore;bool get isHighQuality => (!isBlurry) && hasHighScore;diff --git a/mobile/lib/services/face_ml/face_filtering/face_filtering_constants.dart b/mobile/lib/services/face_ml/face_filtering/face_filtering_constants.dartindex 478161f22b..a1970fd4d6 100644--- a/mobile/lib/services/face_ml/face_filtering/face_filtering_constants.dart+++ b/mobile/lib/services/face_ml/face_filtering/face_filtering_constants.dart@@ -1,8 +1,13 @@+import "package:photos/services/face_ml/face_detection/yolov5face/onnx_face_detection.dart";+/// Blur detection thresholdconst kLaplacianThreshold = 15;/// Default blur valueconst kLapacianDefault = 10000.0;-/// The minimum score for a face to be considered a face-const kMinFaceScore = 0.78;\ No newline at end of file+/// The minimum score for a face to be considered a high quality face for clustering and person detection+const kMinHighQualityFaceScore = 0.78;++/// The minimum score for a face to be detected, regardless of quality. Use [kMinHighQualityFaceScore] for high quality faces.+const kMinFaceDetectionScore = YoloOnnxFaceDetection.kMinScoreSigmoidThreshold;diff --git a/mobile/lib/services/face_ml/face_ml_service.dart b/mobile/lib/services/face_ml/face_ml_service.dartindex db3931ed7d..a3b36e192d 100644--- a/mobile/lib/services/face_ml/face_ml_service.dart+++ b/mobile/lib/services/face_ml/face_ml_service.dart@@ -362,7 +362,9 @@ class FaceMlService {await clusterAllImages();}- Future<void> clusterAllImages({double minFaceScore = kMinFaceScore}) async {+ Future<void> clusterAllImages({+ double minFaceScore = kMinHighQualityFaceScore,+ }) async {_logger.info("`clusterAllImages()` called");try {