[mob][photos] Fix clustering progress number
This commit is contained in:
parent
4fa59ce258
commit
c3fb472287
3 changed files with 28 additions and 14 deletions
|
@ -13,6 +13,8 @@ import "package:photos/face/model/face.dart";
|
||||||
import "package:photos/models/file/file.dart";
|
import "package:photos/models/file/file.dart";
|
||||||
import "package:photos/services/machine_learning/face_ml/face_clustering/face_info_for_clustering.dart";
|
import "package:photos/services/machine_learning/face_ml/face_clustering/face_info_for_clustering.dart";
|
||||||
import 'package:photos/services/machine_learning/face_ml/face_filtering/face_filtering_constants.dart';
|
import 'package:photos/services/machine_learning/face_ml/face_filtering/face_filtering_constants.dart';
|
||||||
|
import "package:photos/services/machine_learning/face_ml/face_ml_result.dart";
|
||||||
|
import "package:photos/utils/ml_util.dart";
|
||||||
import 'package:sqlite_async/sqlite_async.dart';
|
import 'package:sqlite_async/sqlite_async.dart';
|
||||||
|
|
||||||
/// Stores all data for the FacesML-related features. The database can be accessed by `FaceMLDataDB.instance.database`.
|
/// Stores all data for the FacesML-related features. The database can be accessed by `FaceMLDataDB.instance.database`.
|
||||||
|
@ -401,8 +403,10 @@ class FaceMLDataDB {
|
||||||
final personID = map[personIdColumn] as String;
|
final personID = map[personIdColumn] as String;
|
||||||
final clusterID = map[fcClusterID] as int;
|
final clusterID = map[fcClusterID] as int;
|
||||||
final faceID = map[fcFaceId] as String;
|
final faceID = map[fcFaceId] as String;
|
||||||
result.putIfAbsent(personID, () => {}).putIfAbsent(clusterID, () => {})
|
result
|
||||||
.add(faceID);
|
.putIfAbsent(personID, () => {})
|
||||||
|
.putIfAbsent(clusterID, () => {})
|
||||||
|
.add(faceID);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -673,11 +677,24 @@ class FaceMLDataDB {
|
||||||
return maps.first['count'] as int;
|
return maps.first['count'] as int;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<double> getClusteredToTotalFacesRatio() async {
|
Future<int> getClusteredFileCount() async {
|
||||||
final int totalFaces = await getTotalFaceCount();
|
final db = await instance.asyncDB;
|
||||||
final int clusteredFaces = await getClusteredFaceCount();
|
final List<Map<String, dynamic>> maps = await db.getAll(
|
||||||
|
'SELECT COUNT(DISTINCT $fcFaceId) as count FROM $faceClustersTable',
|
||||||
|
);
|
||||||
|
final Set<int> fileIDs = {};
|
||||||
|
for (final map in maps) {
|
||||||
|
final int fileID = getFileIdFromFaceId(map[fcFaceId] as String);
|
||||||
|
fileIDs.add(fileID);
|
||||||
|
}
|
||||||
|
return fileIDs.length;
|
||||||
|
}
|
||||||
|
|
||||||
return clusteredFaces / totalFaces;
|
Future<double> getClusteredToIndexableFilesRatio() async {
|
||||||
|
final int indexableFiles = (await getIndexableFileIDs()).length;
|
||||||
|
final int clusteredFiles = await getClusteredFileCount();
|
||||||
|
|
||||||
|
return clusteredFiles / indexableFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int> getBlurryFaceCount([
|
Future<int> getBlurryFaceCount([
|
||||||
|
|
|
@ -177,7 +177,7 @@ class _FaceDebugSectionWidgetState extends State<FaceDebugSectionWidget> {
|
||||||
sectionOptionSpacing,
|
sectionOptionSpacing,
|
||||||
MenuItemWidget(
|
MenuItemWidget(
|
||||||
captionedTextWidget: FutureBuilder<double>(
|
captionedTextWidget: FutureBuilder<double>(
|
||||||
future: FaceMLDataDB.instance.getClusteredToTotalFacesRatio(),
|
future: FaceMLDataDB.instance.getClusteredToIndexableFilesRatio(),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
return CaptionedTextWidget(
|
return CaptionedTextWidget(
|
||||||
|
|
|
@ -439,19 +439,16 @@ class FaceRecognitionStatusWidgetState
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<(int, int, int, double)> getIndexStatus() async {
|
Future<(int, int, double)> getIndexStatus() async {
|
||||||
try {
|
try {
|
||||||
final indexedFiles = await FaceMLDataDB.instance
|
final indexedFiles = await FaceMLDataDB.instance
|
||||||
.getIndexedFileCount(minimumMlVersion: faceMlVersion);
|
.getIndexedFileCount(minimumMlVersion: faceMlVersion);
|
||||||
final indexableFiles = (await getIndexableFileIDs()).length;
|
final indexableFiles = (await getIndexableFileIDs()).length;
|
||||||
final showIndexedFiles = min(indexedFiles, indexableFiles);
|
final showIndexedFiles = min(indexedFiles, indexableFiles);
|
||||||
final pendingFiles = max(indexableFiles - indexedFiles, 0);
|
final pendingFiles = max(indexableFiles - indexedFiles, 0);
|
||||||
final foundFaces = await FaceMLDataDB.instance.getTotalFaceCount();
|
final clusteringDoneRatio = await FaceMLDataDB.instance.getClusteredToIndexableFilesRatio();
|
||||||
final clusteredFaces =
|
|
||||||
await FaceMLDataDB.instance.getClusteredFaceCount();
|
|
||||||
final clusteringDoneRatio = clusteredFaces / foundFaces;
|
|
||||||
|
|
||||||
return (showIndexedFiles, pendingFiles, foundFaces, clusteringDoneRatio);
|
return (showIndexedFiles, pendingFiles, clusteringDoneRatio);
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
_logger.severe('Error getting face recognition status', e, s);
|
_logger.severe('Error getting face recognition status', e, s);
|
||||||
rethrow;
|
rethrow;
|
||||||
|
@ -480,7 +477,7 @@ class FaceRecognitionStatusWidgetState
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
final int indexedFiles = snapshot.data!.$1;
|
final int indexedFiles = snapshot.data!.$1;
|
||||||
final int pendingFiles = snapshot.data!.$2;
|
final int pendingFiles = snapshot.data!.$2;
|
||||||
final double clusteringDoneRatio = snapshot.data!.$4;
|
final double clusteringDoneRatio = snapshot.data!.$3;
|
||||||
final double clusteringPercentage =
|
final double clusteringPercentage =
|
||||||
(clusteringDoneRatio * 100).clamp(0, 100);
|
(clusteringDoneRatio * 100).clamp(0, 100);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue