Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Rename

laurenspriem47ac7e0c9ca2
diff --git a/mobile/lib/main.dart b/mobile/lib/main.dart
index 18148c897d..0ca8f28ebf 100644
--- a/mobile/lib/main.dart
+++ b/mobile/lib/main.dart
@@ -292,7 +292,7 @@ Future<void> _init(bool isBackground, {String via = ''}) async {
_logger.info("MachineLearningController done");
if (flagService.faceSearchEnabled) {
- unawaited(FaceMlService.instance.init());
+ unawaited(MLService.instance.init());
} else {
if (LocalSettings.instance.isFaceIndexingEnabled) {
unawaited(LocalSettings.instance.toggleFaceIndexing());
diff --git a/mobile/lib/services/machine_learning/ml_service.dart b/mobile/lib/services/machine_learning/ml_service.dart
index f7642c2a57..da9658d6c1 100644
--- a/mobile/lib/services/machine_learning/ml_service.dart
+++ b/mobile/lib/services/machine_learning/ml_service.dart
@@ -47,7 +47,7 @@ enum FaceMlOperation { analyzeImage }
/// WARNING: For getting the ML results needed for the UI, you should use `FaceSearchService` instead of this class!
///
/// The pipeline consists of face detection, face alignment and face embedding.
-class FaceMlService {
+class MLService {
final _logger = Logger("FaceMlService");
// Flutter isolate things for running the image ml pipeline
@@ -59,9 +59,9 @@ class FaceMlService {
late SendPort _mainSendPort;
// Singleton pattern
- FaceMlService._privateConstructor();
- static final instance = FaceMlService._privateConstructor();
- factory FaceMlService() => instance;
+ MLService._privateConstructor();
+ static final instance = MLService._privateConstructor();
+ factory MLService() => instance;
final _initModelLock = Lock();
final _functionLock = Lock();
@@ -77,6 +77,8 @@ class FaceMlService {
bool get showClusteringIsHappening => _showClusteringIsHappening;
+ bool get allModelsLoaded => _isModelsInitialized;
+
bool debugIndexingDisabled = false;
bool _showClusteringIsHappening = false;
bool _mlControllerStatus = false;
@@ -614,7 +616,7 @@ class FaceMlService {
switch (function) {
case FaceMlOperation.analyzeImage:
final time = DateTime.now();
- final MLResult result = await FaceMlService._analyzeImageSync(args);
+ final MLResult result = await MLService._analyzeImageSync(args);
dev.log(
"`analyzeImageSync` function executed in ${DateTime.now().difference(time).inMilliseconds} ms",
);
diff --git a/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart b/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart
index 825fba3dcf..19a90ead9b 100644
--- a/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart
+++ b/mobile/lib/ui/settings/debug/ml_debug_section_widget.dart
@@ -79,7 +79,7 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
final isEnabled =
await LocalSettings.instance.toggleFaceIndexing();
if (!isEnabled) {
- FaceMlService.instance.pauseIndexingAndClustering();
+ MLService.instance.pauseIndexingAndClustering();
}
if (mounted) {
setState(() {});
@@ -115,7 +115,7 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
sectionOptionSpacing,
MenuItemWidget(
captionedTextWidget: CaptionedTextWidget(
- title: FaceMlService.instance.debugIndexingDisabled
+ title: MLService.instance.debugIndexingDisabled
? "Debug enable indexing again"
: "Debug disable indexing",
),
@@ -124,10 +124,10 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
trailingIconIsMuted: true,
onTap: () async {
try {
- FaceMlService.instance.debugIndexingDisabled =
- !FaceMlService.instance.debugIndexingDisabled;
- if (FaceMlService.instance.debugIndexingDisabled) {
- FaceMlService.instance.pauseIndexingAndClustering();
+ MLService.instance.debugIndexingDisabled =
+ !MLService.instance.debugIndexingDisabled;
+ if (MLService.instance.debugIndexingDisabled) {
+ MLService.instance.pauseIndexingAndClustering();
}
if (mounted) {
setState(() {});
@@ -148,8 +148,8 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
trailingIconIsMuted: true,
onTap: () async {
try {
- FaceMlService.instance.debugIndexingDisabled = false;
- unawaited(FaceMlService.instance.runAllML());
+ MLService.instance.debugIndexingDisabled = false;
+ unawaited(MLService.instance.runAllML());
} catch (e, s) {
_logger.warning('indexAndClusterAll failed ', e, s);
await showGenericErrorDialog(context: context, error: e);
@@ -166,8 +166,8 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
trailingIconIsMuted: true,
onTap: () async {
try {
- FaceMlService.instance.debugIndexingDisabled = false;
- unawaited(FaceMlService.instance.indexAllImages());
+ MLService.instance.debugIndexingDisabled = false;
+ unawaited(MLService.instance.indexAllImages());
} catch (e, s) {
_logger.warning('indexing failed ', e, s);
await showGenericErrorDialog(context: context, error: e);
@@ -194,9 +194,8 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
onTap: () async {
try {
await PersonService.instance.fetchRemoteClusterFeedback();
- FaceMlService.instance.debugIndexingDisabled = false;
- await FaceMlService.instance
- .clusterAllImages(clusterInBuckets: true);
+ MLService.instance.debugIndexingDisabled = false;
+ await MLService.instance.clusterAllImages(clusterInBuckets: true);
Bus.instance.fire(PeopleChangedEvent());
showShortToast(context, "Done");
} catch (e, s) {