mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
[mob] Show clustered percentage in UI
This commit is contained in:
parent
5cf10c9c9b
commit
8801dc1a7a
@ -513,6 +513,22 @@ class FaceMLDataDB {
|
||||
return maps.first['count'] as int;
|
||||
}
|
||||
|
||||
Future<double> getClusteredToTotalFacesRatio() async {
|
||||
final db = await instance.sqliteAsyncDB;
|
||||
|
||||
final List<Map<String, dynamic>> totalFacesMaps = await db.getAll(
|
||||
'SELECT COUNT(*) as count FROM $facesTable WHERE $faceScore > $kMinHighQualityFaceScore AND $faceBlur > $kLaplacianThreshold',
|
||||
);
|
||||
final int totalFaces = totalFacesMaps.first['count'] as int;
|
||||
|
||||
final List<Map<String, dynamic>> clusteredFacesMaps = await db.getAll(
|
||||
'SELECT COUNT(DISTINCT $fcFaceId) as count FROM $faceClustersTable',
|
||||
);
|
||||
final int clusteredFaces = clusteredFacesMaps.first['count'] as int;
|
||||
|
||||
return clusteredFaces / totalFaces;
|
||||
}
|
||||
|
||||
Future<int> getBlurryFaceCount([
|
||||
int blurThreshold = kLaplacianThreshold,
|
||||
]) async {
|
||||
|
@ -367,11 +367,10 @@ class FaceMlService {
|
||||
_logger.info("`clusterAllImages()` called");
|
||||
|
||||
try {
|
||||
// Get a sense of the total number of faces in the database
|
||||
final int totalFaces = await FaceMLDataDB.instance
|
||||
.getTotalFaceCount(minFaceScore: minFaceScore);
|
||||
if (clusterInBuckets) {
|
||||
// Get a sense of the total number of faces in the database
|
||||
final int totalFaces = await FaceMLDataDB.instance
|
||||
.getTotalFaceCount(minFaceScore: minFaceScore);
|
||||
|
||||
// read the creation times from Files DB, in a map from fileID to creation time
|
||||
final fileIDToCreationTime =
|
||||
await FilesDB.instance.getFileIDToCreationTime();
|
||||
@ -419,9 +418,6 @@ class FaceMlService {
|
||||
bucket++;
|
||||
}
|
||||
} else {
|
||||
final int totalFaces = await FaceMLDataDB.instance
|
||||
.getTotalFaceCount(minFaceScore: minFaceScore);
|
||||
|
||||
// Read all the embeddings from the database, in a map from faceID to embedding
|
||||
final clusterStartTime = DateTime.now();
|
||||
final faceIdToEmbedding =
|
||||
@ -463,6 +459,7 @@ class FaceMlService {
|
||||
_logger.info('Done updating FaceIDs with clusterIDs in the DB, in '
|
||||
'${DateTime.now().difference(clusterDoneTime).inSeconds} seconds');
|
||||
}
|
||||
_logger.info('clusterAllImages() finished');
|
||||
} catch (e, s) {
|
||||
_logger.severe("`clusterAllImages` failed", e, s);
|
||||
}
|
||||
|
@ -179,12 +179,13 @@ class _FaceDebugSectionWidgetState extends State<FaceDebugSectionWidget> {
|
||||
// },
|
||||
// ),
|
||||
MenuItemWidget(
|
||||
captionedTextWidget: FutureBuilder<int>(
|
||||
future: FaceMLDataDB.instance.getTotalFaceCount(),
|
||||
captionedTextWidget: FutureBuilder<double>(
|
||||
future: FaceMLDataDB.instance.getClusteredToTotalFacesRatio(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return CaptionedTextWidget(
|
||||
title: "Run clustering (${snapshot.data!} faces)",
|
||||
title:
|
||||
"Run clustering (${(100 * snapshot.data!).toStringAsFixed(0)}% done)",
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
|
Loading…
x
Reference in New Issue
Block a user