Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob] Show debug info on blur

laurenspriem78af84450a0c
diff --git a/mobile/lib/face/db.dart b/mobile/lib/face/db.dart
index 024ce41c42..1c37551be1 100644
--- a/mobile/lib/face/db.dart
+++ b/mobile/lib/face/db.dart
@@ -481,6 +481,16 @@ class FaceMLDataDB {
return maps.first['count'] as int;
}
+ Future<int> getBlurryFaceCount([
+ int blurThreshold = kLaplacianThreshold,
+ ]) async {
+ final db = await instance.database;
+ final List<Map<String, dynamic>> maps = await db.rawQuery(
+ 'SELECT COUNT(*) as count FROM $facesTable WHERE $faceBlur <= $blurThreshold AND $faceScore > $kMinHighQualityFaceScore',
+ );
+ return maps.first['count'] as int;
+ }
+
Future<void> resetClusterIDs() async {
final db = await instance.database;
await db.execute(dropFaceClustersTable);
diff --git a/mobile/lib/ui/settings/debug/face_debug_section_widget.dart b/mobile/lib/ui/settings/debug/face_debug_section_widget.dart
index e09574356d..559eed18b6 100644
--- a/mobile/lib/ui/settings/debug/face_debug_section_widget.dart
+++ b/mobile/lib/ui/settings/debug/face_debug_section_widget.dart
@@ -114,7 +114,9 @@ class _FaceDebugSectionWidgetState extends State<FaceDebugSectionWidget> {
.getTotalFaceCount(minFaceScore: 0.75);
final faces78 = await FaceMLDataDB.instance
.getTotalFaceCount(minFaceScore: kMinHighQualityFaceScore);
- showShortToast(context, "Faces75: $faces75, Faces78: $faces78");
+ final blurryFaceCount =
+ await FaceMLDataDB.instance.getBlurryFaceCount(15);
+ showShortToast(context, "$blurryFaceCount blurry faces");
},
),
// MenuItemWidget(
diff --git a/mobile/lib/ui/viewer/file_details/face_widget.dart b/mobile/lib/ui/viewer/file_details/face_widget.dart
index 8366720ad3..1620149959 100644
--- a/mobile/lib/ui/viewer/file_details/face_widget.dart
+++ b/mobile/lib/ui/viewer/file_details/face_widget.dart
@@ -162,6 +162,12 @@ class _FaceWidgetState extends State<FaceWidget> {
style: Theme.of(context).textTheme.bodySmall,
maxLines: 1,
),
+ if (kDebugMode)
+ Text(
+ 'B: ${widget.face.blur.toStringAsFixed(3)}',
+ style: Theme.of(context).textTheme.bodySmall,
+ maxLines: 1,
+ ),
// if (kDebugMode)
// if (highlight)
// const Text(
diff --git a/mobile/lib/ui/viewer/file_details/faces_item_widget.dart b/mobile/lib/ui/viewer/file_details/faces_item_widget.dart
index 505dbf43bd..d06f839747 100644
--- a/mobile/lib/ui/viewer/file_details/faces_item_widget.dart
+++ b/mobile/lib/ui/viewer/file_details/faces_item_widget.dart
@@ -1,3 +1,4 @@
+import "package:flutter/foundation.dart" show kDebugMode;
import "package:flutter/material.dart";
import "package:logging/logging.dart";
import "package:photos/face/db.dart";
@@ -68,8 +69,13 @@ class _FacesItemWidgetState extends State<FacesItemWidget> {
),
];
}
- if (faces.isEmpty ||
- faces.every((face) => face.score < 0.75 || face.isBlurry)) {
+
+ // Remove faces with low scores and blurry faces
+ if (!kDebugMode) {
+ faces.removeWhere((face) => (face.isBlurry || face.score < 0.75));
+ }
+
+ if (faces.isEmpty) {
return [
const ChipButtonWidget(
"No faces found",
@@ -81,9 +87,6 @@ class _FacesItemWidgetState extends State<FacesItemWidget> {
// Sort the faces by score in descending order, so that the highest scoring face is first.
faces.sort((Face a, Face b) => b.score.compareTo(a.score));
- // Remove faces with low scores and blurry faces
- faces.removeWhere((face) => (face.isBlurry || face.score < 0.75));
-
// TODO: add deduplication of faces of same person
final faceIdsToClusterIds = await FaceMLDataDB.instance
.getFaceIdsToClusterIds(faces.map((face) => face.faceID));