[mob][photos] Show faces index status in settings

This commit is contained in:
laurenspriem 2024-05-16 17:28:09 +05:30
parent 1932a92cb8
commit d9232c1b83
27 changed files with 159 additions and 13 deletions

View file

@ -51,6 +51,7 @@ class MessageLookup extends MessageLookupByLibrary {
"faceRecognitionIndexingDescription": MessageLookupByLibrary.simpleMessage( "faceRecognitionIndexingDescription": MessageLookupByLibrary.simpleMessage(
"Please note that this will result in a higher bandwidth and battery usage until all items are indexed."), "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."),
"fileTypes": MessageLookupByLibrary.simpleMessage("File types"), "fileTypes": MessageLookupByLibrary.simpleMessage("File types"),
"foundFaces": MessageLookupByLibrary.simpleMessage("Found faces"),
"joinDiscord": MessageLookupByLibrary.simpleMessage("Join Discord"), "joinDiscord": MessageLookupByLibrary.simpleMessage("Join Discord"),
"locations": MessageLookupByLibrary.simpleMessage("Locations"), "locations": MessageLookupByLibrary.simpleMessage("Locations"),
"longPressAnEmailToVerifyEndToEndEncryption": "longPressAnEmailToVerifyEndToEndEncryption":

View file

@ -752,6 +752,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Als Erinnerung"), MessageLookupByLibrary.simpleMessage("Als Erinnerung"),
"forgotPassword": "forgotPassword":
MessageLookupByLibrary.simpleMessage("Passwort vergessen"), MessageLookupByLibrary.simpleMessage("Passwort vergessen"),
"foundFaces": MessageLookupByLibrary.simpleMessage("Found faces"),
"freeStorageClaimed": MessageLookupByLibrary.simpleMessage( "freeStorageClaimed": MessageLookupByLibrary.simpleMessage(
"Kostenlos hinzugefügter Speicherplatz"), "Kostenlos hinzugefügter Speicherplatz"),
"freeStorageOnReferralSuccess": m24, "freeStorageOnReferralSuccess": m24,

View file

@ -750,6 +750,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("for your memories"), MessageLookupByLibrary.simpleMessage("for your memories"),
"forgotPassword": "forgotPassword":
MessageLookupByLibrary.simpleMessage("Forgot password"), MessageLookupByLibrary.simpleMessage("Forgot password"),
"foundFaces": MessageLookupByLibrary.simpleMessage("Found faces"),
"freeStorageClaimed": "freeStorageClaimed":
MessageLookupByLibrary.simpleMessage("Free storage claimed"), MessageLookupByLibrary.simpleMessage("Free storage claimed"),
"freeStorageOnReferralSuccess": m24, "freeStorageOnReferralSuccess": m24,

View file

@ -653,6 +653,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("para tus recuerdos"), MessageLookupByLibrary.simpleMessage("para tus recuerdos"),
"forgotPassword": "forgotPassword":
MessageLookupByLibrary.simpleMessage("Olvidé mi contraseña"), MessageLookupByLibrary.simpleMessage("Olvidé mi contraseña"),
"foundFaces": MessageLookupByLibrary.simpleMessage("Found faces"),
"freeStorageClaimed": MessageLookupByLibrary.simpleMessage( "freeStorageClaimed": MessageLookupByLibrary.simpleMessage(
"Almacenamiento gratuito reclamado"), "Almacenamiento gratuito reclamado"),
"freeStorageOnReferralSuccess": m24, "freeStorageOnReferralSuccess": m24,

View file

@ -738,6 +738,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("pour vos souvenirs"), MessageLookupByLibrary.simpleMessage("pour vos souvenirs"),
"forgotPassword": "forgotPassword":
MessageLookupByLibrary.simpleMessage("Mot de passe oublié"), MessageLookupByLibrary.simpleMessage("Mot de passe oublié"),
"foundFaces": MessageLookupByLibrary.simpleMessage("Found faces"),
"freeStorageClaimed": "freeStorageClaimed":
MessageLookupByLibrary.simpleMessage("Stockage gratuit réclamé"), MessageLookupByLibrary.simpleMessage("Stockage gratuit réclamé"),
"freeStorageOnReferralSuccess": m24, "freeStorageOnReferralSuccess": m24,

View file

@ -710,6 +710,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("per i tuoi ricordi"), MessageLookupByLibrary.simpleMessage("per i tuoi ricordi"),
"forgotPassword": "forgotPassword":
MessageLookupByLibrary.simpleMessage("Password dimenticata"), MessageLookupByLibrary.simpleMessage("Password dimenticata"),
"foundFaces": MessageLookupByLibrary.simpleMessage("Found faces"),
"freeStorageClaimed": "freeStorageClaimed":
MessageLookupByLibrary.simpleMessage("Spazio gratuito richiesto"), MessageLookupByLibrary.simpleMessage("Spazio gratuito richiesto"),
"freeStorageOnReferralSuccess": m24, "freeStorageOnReferralSuccess": m24,

View file

@ -51,6 +51,7 @@ class MessageLookup extends MessageLookupByLibrary {
"faceRecognitionIndexingDescription": MessageLookupByLibrary.simpleMessage( "faceRecognitionIndexingDescription": MessageLookupByLibrary.simpleMessage(
"Please note that this will result in a higher bandwidth and battery usage until all items are indexed."), "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."),
"fileTypes": MessageLookupByLibrary.simpleMessage("File types"), "fileTypes": MessageLookupByLibrary.simpleMessage("File types"),
"foundFaces": MessageLookupByLibrary.simpleMessage("Found faces"),
"joinDiscord": MessageLookupByLibrary.simpleMessage("Join Discord"), "joinDiscord": MessageLookupByLibrary.simpleMessage("Join Discord"),
"locations": MessageLookupByLibrary.simpleMessage("Locations"), "locations": MessageLookupByLibrary.simpleMessage("Locations"),
"longPressAnEmailToVerifyEndToEndEncryption": "longPressAnEmailToVerifyEndToEndEncryption":

View file

@ -775,6 +775,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("voor uw herinneringen"), MessageLookupByLibrary.simpleMessage("voor uw herinneringen"),
"forgotPassword": "forgotPassword":
MessageLookupByLibrary.simpleMessage("Wachtwoord vergeten"), MessageLookupByLibrary.simpleMessage("Wachtwoord vergeten"),
"foundFaces": MessageLookupByLibrary.simpleMessage("Found faces"),
"freeStorageClaimed": "freeStorageClaimed":
MessageLookupByLibrary.simpleMessage("Gratis opslag geclaimd"), MessageLookupByLibrary.simpleMessage("Gratis opslag geclaimd"),
"freeStorageOnReferralSuccess": m24, "freeStorageOnReferralSuccess": m24,

View file

@ -69,6 +69,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Please note that this will result in a higher bandwidth and battery usage until all items are indexed."), "Please note that this will result in a higher bandwidth and battery usage until all items are indexed."),
"feedback": MessageLookupByLibrary.simpleMessage("Tilbakemelding"), "feedback": MessageLookupByLibrary.simpleMessage("Tilbakemelding"),
"fileTypes": MessageLookupByLibrary.simpleMessage("File types"), "fileTypes": MessageLookupByLibrary.simpleMessage("File types"),
"foundFaces": MessageLookupByLibrary.simpleMessage("Found faces"),
"invalidEmailAddress": "invalidEmailAddress":
MessageLookupByLibrary.simpleMessage("Ugyldig e-postadresse"), MessageLookupByLibrary.simpleMessage("Ugyldig e-postadresse"),
"joinDiscord": MessageLookupByLibrary.simpleMessage("Join Discord"), "joinDiscord": MessageLookupByLibrary.simpleMessage("Join Discord"),

View file

@ -119,6 +119,7 @@ class MessageLookup extends MessageLookupByLibrary {
"fileTypes": MessageLookupByLibrary.simpleMessage("File types"), "fileTypes": MessageLookupByLibrary.simpleMessage("File types"),
"forgotPassword": "forgotPassword":
MessageLookupByLibrary.simpleMessage("Nie pamiętam hasła"), MessageLookupByLibrary.simpleMessage("Nie pamiętam hasła"),
"foundFaces": MessageLookupByLibrary.simpleMessage("Found faces"),
"generatingEncryptionKeys": MessageLookupByLibrary.simpleMessage( "generatingEncryptionKeys": MessageLookupByLibrary.simpleMessage(
"Generowanie kluczy szyfrujących..."), "Generowanie kluczy szyfrujących..."),
"howItWorks": MessageLookupByLibrary.simpleMessage("Jak to działa"), "howItWorks": MessageLookupByLibrary.simpleMessage("Jak to działa"),

View file

@ -763,6 +763,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("para suas memórias"), MessageLookupByLibrary.simpleMessage("para suas memórias"),
"forgotPassword": "forgotPassword":
MessageLookupByLibrary.simpleMessage("Esqueceu sua senha"), MessageLookupByLibrary.simpleMessage("Esqueceu sua senha"),
"foundFaces": MessageLookupByLibrary.simpleMessage("Found faces"),
"freeStorageClaimed": MessageLookupByLibrary.simpleMessage( "freeStorageClaimed": MessageLookupByLibrary.simpleMessage(
"Armazenamento gratuito reivindicado"), "Armazenamento gratuito reivindicado"),
"freeStorageOnReferralSuccess": m24, "freeStorageOnReferralSuccess": m24,

View file

@ -630,6 +630,7 @@ class MessageLookup extends MessageLookupByLibrary {
"flip": MessageLookupByLibrary.simpleMessage("上下翻转"), "flip": MessageLookupByLibrary.simpleMessage("上下翻转"),
"forYourMemories": MessageLookupByLibrary.simpleMessage("为您的回忆"), "forYourMemories": MessageLookupByLibrary.simpleMessage("为您的回忆"),
"forgotPassword": MessageLookupByLibrary.simpleMessage("忘记密码"), "forgotPassword": MessageLookupByLibrary.simpleMessage("忘记密码"),
"foundFaces": MessageLookupByLibrary.simpleMessage("Found faces"),
"freeStorageClaimed": MessageLookupByLibrary.simpleMessage("已领取的免费存储"), "freeStorageClaimed": MessageLookupByLibrary.simpleMessage("已领取的免费存储"),
"freeStorageOnReferralSuccess": m24, "freeStorageOnReferralSuccess": m24,
"freeStorageSpace": m25, "freeStorageSpace": m25,

View file

@ -8773,6 +8773,16 @@ class S {
args: [], args: [],
); );
} }
/// `Found faces`
String get foundFaces {
return Intl.message(
'Found faces',
name: 'foundFaces',
desc: '',
args: [],
);
}
} }
class AppLocalizationDelegate extends LocalizationsDelegate<S> { class AppLocalizationDelegate extends LocalizationsDelegate<S> {

View file

@ -22,5 +22,6 @@
"enterPersonName": "Enter person name", "enterPersonName": "Enter person name",
"removePersonLabel": "Remove person label", "removePersonLabel": "Remove person label",
"faceRecognition": "Face recognition", "faceRecognition": "Face recognition",
"faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed." "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed.",
"foundFaces": "Found faces"
} }

View file

@ -1210,5 +1210,6 @@
"enterPersonName": "Enter person name", "enterPersonName": "Enter person name",
"removePersonLabel": "Remove person label", "removePersonLabel": "Remove person label",
"faceRecognition": "Face recognition", "faceRecognition": "Face recognition",
"faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed." "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed.",
"foundFaces": "Found faces"
} }

View file

@ -1233,5 +1233,6 @@
"autoPair": "Auto pair", "autoPair": "Auto pair",
"pairWithPin": "Pair with PIN", "pairWithPin": "Pair with PIN",
"faceRecognition": "Face recognition", "faceRecognition": "Face recognition",
"faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed." "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed.",
"foundFaces": "Found faces"
} }

View file

@ -984,5 +984,6 @@
"enterPersonName": "Enter person name", "enterPersonName": "Enter person name",
"removePersonLabel": "Remove person label", "removePersonLabel": "Remove person label",
"faceRecognition": "Face recognition", "faceRecognition": "Face recognition",
"faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed." "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed.",
"foundFaces": "Found faces"
} }

View file

@ -1165,5 +1165,6 @@
"enterPersonName": "Enter person name", "enterPersonName": "Enter person name",
"removePersonLabel": "Remove person label", "removePersonLabel": "Remove person label",
"faceRecognition": "Face recognition", "faceRecognition": "Face recognition",
"faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed." "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed.",
"foundFaces": "Found faces"
} }

View file

@ -1127,5 +1127,6 @@
"enterPersonName": "Enter person name", "enterPersonName": "Enter person name",
"removePersonLabel": "Remove person label", "removePersonLabel": "Remove person label",
"faceRecognition": "Face recognition", "faceRecognition": "Face recognition",
"faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed." "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed.",
"foundFaces": "Found faces"
} }

View file

@ -22,5 +22,6 @@
"enterPersonName": "Enter person name", "enterPersonName": "Enter person name",
"removePersonLabel": "Remove person label", "removePersonLabel": "Remove person label",
"faceRecognition": "Face recognition", "faceRecognition": "Face recognition",
"faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed." "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed.",
"foundFaces": "Found faces"
} }

View file

@ -1228,5 +1228,6 @@
"castIPMismatchBody": "Zorg ervoor dat je op hetzelfde netwerk zit als de tv.", "castIPMismatchBody": "Zorg ervoor dat je op hetzelfde netwerk zit als de tv.",
"pairingComplete": "Koppeling voltooid", "pairingComplete": "Koppeling voltooid",
"faceRecognition": "Face recognition", "faceRecognition": "Face recognition",
"faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed." "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed.",
"foundFaces": "Found faces"
} }

View file

@ -36,5 +36,6 @@
"enterPersonName": "Enter person name", "enterPersonName": "Enter person name",
"removePersonLabel": "Remove person label", "removePersonLabel": "Remove person label",
"faceRecognition": "Face recognition", "faceRecognition": "Face recognition",
"faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed." "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed.",
"foundFaces": "Found faces"
} }

View file

@ -123,5 +123,6 @@
"enterPersonName": "Enter person name", "enterPersonName": "Enter person name",
"removePersonLabel": "Remove person label", "removePersonLabel": "Remove person label",
"faceRecognition": "Face recognition", "faceRecognition": "Face recognition",
"faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed." "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed.",
"foundFaces": "Found faces"
} }

View file

@ -1228,5 +1228,6 @@
"castIPMismatchBody": "Certifique-se de estar na mesma rede que a TV.", "castIPMismatchBody": "Certifique-se de estar na mesma rede que a TV.",
"pairingComplete": "Pareamento concluído", "pairingComplete": "Pareamento concluído",
"faceRecognition": "Face recognition", "faceRecognition": "Face recognition",
"faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed." "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed.",
"foundFaces": "Found faces"
} }

View file

@ -1228,5 +1228,6 @@
"castIPMismatchBody": "请确保您的设备与电视处于同一网络。", "castIPMismatchBody": "请确保您的设备与电视处于同一网络。",
"pairingComplete": "配对完成", "pairingComplete": "配对完成",
"faceRecognition": "Face recognition", "faceRecognition": "Face recognition",
"faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed." "faceRecognitionIndexingDescription": "Please note that this will result in a higher bandwidth and battery usage until all items are indexed.",
"foundFaces": "Found faces"
} }

View file

@ -1423,7 +1423,7 @@ class FaceMlService {
return ratio; return ratio;
} }
Future<int> getIndexableFilesCount() async { static Future<int> getIndexableFilesCount() async {
final List<EnteFile> enteFiles = await SearchService.instance.getAllFiles(); final List<EnteFile> enteFiles = await SearchService.instance.getAllFiles();
final List<EnteFile> indexableFiles = []; final List<EnteFile> indexableFiles = [];
for (final enteFile in enteFiles) { for (final enteFile in enteFiles) {

View file

@ -1,10 +1,13 @@
import "dart:async"; import "dart:async";
import "dart:math" show max;
import "package:flutter/material.dart"; import "package:flutter/material.dart";
import "package:intl/intl.dart"; import "package:intl/intl.dart";
import "package:photos/core/event_bus.dart"; import "package:photos/core/event_bus.dart";
import 'package:photos/events/embedding_updated_event.dart'; import 'package:photos/events/embedding_updated_event.dart';
import "package:photos/face/db.dart";
import "package:photos/generated/l10n.dart"; import "package:photos/generated/l10n.dart";
import "package:photos/models/ml/ml_versions.dart";
import "package:photos/service_locator.dart"; import "package:photos/service_locator.dart";
import "package:photos/services/machine_learning/face_ml/face_ml_service.dart"; import "package:photos/services/machine_learning/face_ml/face_ml_service.dart";
import 'package:photos/services/machine_learning/semantic_search/frameworks/ml_framework.dart'; import 'package:photos/services/machine_learning/semantic_search/frameworks/ml_framework.dart';
@ -216,6 +219,9 @@ class _MachineLearningSettingsPageState
const SizedBox( const SizedBox(
height: 12, height: 12,
), ),
hasEnabled
? const FaceRecognitionStatusWidget()
: const SizedBox.shrink(),
], ],
); );
} }
@ -348,3 +354,109 @@ class _MagicSearchIndexStatsWidgetState
); );
} }
} }
class FaceRecognitionStatusWidget extends StatefulWidget {
const FaceRecognitionStatusWidget({
super.key,
});
@override
State<FaceRecognitionStatusWidget> createState() =>
FaceRecognitionStatusWidgetState();
}
class FaceRecognitionStatusWidgetState
extends State<FaceRecognitionStatusWidget> {
Timer? _timer;
@override
void initState() {
super.initState();
_timer = Timer.periodic(const Duration(seconds: 5), (timer) {
setState(() {
// Your state update logic here
});
});
}
Future<(int, int, int)> getIndexStatus() async {
final indexedFiles = await FaceMLDataDB.instance
.getIndexedFileCount(minimumMlVersion: faceMlVersion);
final indexableFiles = await FaceMlService.getIndexableFilesCount();
final pendingFiles = max(indexableFiles - indexedFiles, 0);
final foundFaces = await FaceMLDataDB.instance.getTotalFaceCount();
return (indexedFiles, pendingFiles, foundFaces);
}
@override
void dispose() {
_timer?.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Column(
children: [
Row(
children: [
MenuSectionTitle(title: S.of(context).status),
Expanded(child: Container()),
],
),
FutureBuilder(
future: getIndexStatus(),
builder: (context, snapshot) {
if (snapshot.hasData) {
final int indexedFiles = snapshot.data!.$1;
final int pendingFiles = snapshot.data!.$2;
final int foundFaces = snapshot.data!.$3;
return Column(
children: [
MenuItemWidget(
captionedTextWidget: CaptionedTextWidget(
title: S.of(context).indexedItems,
),
trailingWidget: Text(
NumberFormat().format(indexedFiles),
style: Theme.of(context).textTheme.bodySmall,
),
singleBorderRadius: 8,
alignCaptionedTextToLeft: true,
isGestureDetectorDisabled: true,
),
MenuItemWidget(
captionedTextWidget: CaptionedTextWidget(
title: S.of(context).pendingItems,
),
trailingWidget: Text(
NumberFormat().format(pendingFiles),
style: Theme.of(context).textTheme.bodySmall,
),
singleBorderRadius: 8,
alignCaptionedTextToLeft: true,
isGestureDetectorDisabled: true,
),
MenuItemWidget(
captionedTextWidget: CaptionedTextWidget(
title: S.of(context).foundFaces,
),
trailingWidget: Text(
NumberFormat().format(foundFaces),
style: Theme.of(context).textTheme.bodySmall,
),
singleBorderRadius: 8,
alignCaptionedTextToLeft: true,
isGestureDetectorDisabled: true,
),
],
);
}
return const SizedBox.shrink();
},
),
],
);
}
}