diff --git a/mobile/lib/face/db.dart b/mobile/lib/face/db.dart index f192607ec9..e12242987d 100644 --- a/mobile/lib/face/db.dart +++ b/mobile/lib/face/db.dart @@ -344,6 +344,26 @@ class FaceMLDataDB { return maps.map((e) => e[fcFaceId] as String).toSet(); } + Future> getBlurValuesForCluster(int clusterID) async { + final db = await instance.sqliteAsyncDB; + const String query = ''' + SELECT $facesTable.$faceBlur + FROM $facesTable + JOIN $faceClustersTable ON $facesTable.$faceIDColumn = $faceClustersTable.$fcFaceId + WHERE $faceClustersTable.$fcClusterID = ? + '''; + // const String query2 = ''' + // SELECT $faceBlur + // FROM $facesTable + // WHERE $faceIDColumn IN (SELECT $fcFaceId FROM $faceClustersTable WHERE $fcClusterID = ?) + // '''; + final List> maps = await db.getAll( + query, + [clusterID], + ); + return maps.map((e) => e[faceBlur] as double).toSet(); + } + Future> getFaceIdsToClusterIds( Iterable faceIds, ) async { diff --git a/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart b/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart index d1cdb2b7b1..6ce0aeb1cd 100644 --- a/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart +++ b/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart @@ -295,6 +295,30 @@ class ClusterFeedbackService { return clusterIdToFaceIds; } + Future debugLogClusterBlurValues( + int clusterID, { + int? clusterSize, + }) async { + final List blurValues = await FaceMLDataDB.instance + .getBlurValuesForCluster(clusterID) + .then((value) => value.toList()); + + // Round the blur values to integers + final blurValuesIntegers = + blurValues.map((value) => value.round()).toList(); + + // Sort the blur values in ascending order + blurValuesIntegers.sort(); + + // Log the sorted blur values + + _logger.info( + "Blur values for cluster $clusterID${clusterSize != null ? ' with $clusterSize photos' : ''}: $blurValuesIntegers", + ); + + return; + } + /// Returns a map of person's clusterID to map of closest clusterID to with disstance Future>> getSuggestionsUsingMean( PersonEntity p, { diff --git a/mobile/lib/ui/viewer/people/cluster_page.dart b/mobile/lib/ui/viewer/people/cluster_page.dart index e2cdaca525..7c3a7c3370 100644 --- a/mobile/lib/ui/viewer/people/cluster_page.dart +++ b/mobile/lib/ui/viewer/people/cluster_page.dart @@ -1,5 +1,6 @@ import "dart:async"; +import "package:flutter/foundation.dart"; import 'package:flutter/material.dart'; import "package:flutter_animate/flutter_animate.dart"; import 'package:photos/core/event_bus.dart'; @@ -69,6 +70,12 @@ class _ClusterPageState extends State { setState(() {}); } }); + kDebugMode + ? ClusterFeedbackService.instance.debugLogClusterBlurValues( + widget.clusterID, + clusterSize: files.length, + ) + : null; } @override