From f0a19e38aafc46195652737dec986a5560f2823e Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sun, 29 Sep 2024 09:41:35 +0530 Subject: [PATCH 1/6] [mob] Fix hide cluster property --- .../machine_learning/face_ml/feedback/cluster_feedback.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a144fc5fcc..e6462fb8f5 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 @@ -335,7 +335,7 @@ class ClusterFeedbackService { } Future ignoreCluster(String clusterID) async { - await PersonService.instance.addPerson('', clusterID); + await PersonService.instance.addPerson('', clusterID, isHidden: true); Bus.instance.fire(PeopleChangedEvent()); return; } From 772373580afc41a6e6b32f08dfc3b73843ff0bd4 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sun, 29 Sep 2024 09:42:25 +0530 Subject: [PATCH 2/6] [mob] Stop consuming errors for trash --- mobile/lib/services/remote_sync_service.dart | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/mobile/lib/services/remote_sync_service.dart b/mobile/lib/services/remote_sync_service.dart index c1348ba45f..b5f1fecd82 100644 --- a/mobile/lib/services/remote_sync_service.dart +++ b/mobile/lib/services/remote_sync_service.dart @@ -121,13 +121,7 @@ class RemoteSyncService { await syncDeviceCollectionFilesForUpload(); } await _pullDiff(); - // sync trash but consume error during initial launch. - // this is to ensure that we don't pause upload due to any error during - // the trash sync. Impact: We may end up re-uploading a file which was - // recently trashed. - await TrashSyncService.instance - .syncTrash() - .onError((e, s) => _logger.severe('trash sync failed', e, s)); + await TrashSyncService.instance.syncTrash(); if (!hasSyncedBefore) { await _prefs.setBool(_isFirstRemoteSyncDone, true); await syncDeviceCollectionFilesForUpload(); From 675b7f6cea3ae9edd8a27df6e8938863c0eb9002 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sun, 29 Sep 2024 09:45:48 +0530 Subject: [PATCH 3/6] [mob] Sync cgroup as part of ML --- mobile/lib/services/entity_service.dart | 9 ++++++++- .../face_ml/face_recognition_service.dart | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mobile/lib/services/entity_service.dart b/mobile/lib/services/entity_service.dart index 22089e7737..713ba9717e 100644 --- a/mobile/lib/services/entity_service.dart +++ b/mobile/lib/services/entity_service.dart @@ -107,6 +107,14 @@ class EntityService { } } + Future syncEntity(EntityType type) async { + try { + await _remoteToLocalSync(type); + } catch (e) { + _logger.severe("Failed to sync entities", e); + } + } + Future _remoteToLocalSync(EntityType type) async { final int lastSyncTime = _prefs.getInt(_getEntityLastSyncTimePrefix(type)) ?? 0; @@ -116,7 +124,6 @@ class EntityService { limit: fetchLimit, ); if (result.isEmpty) { - debugPrint("No $type entries to sync"); return; } final bool hasMoreItems = result.length == fetchLimit; diff --git a/mobile/lib/services/machine_learning/face_ml/face_recognition_service.dart b/mobile/lib/services/machine_learning/face_ml/face_recognition_service.dart index 91eda670f8..4c42cd3fdc 100644 --- a/mobile/lib/services/machine_learning/face_ml/face_recognition_service.dart +++ b/mobile/lib/services/machine_learning/face_ml/face_recognition_service.dart @@ -6,6 +6,8 @@ import "package:logging/logging.dart"; import "package:photos/core/event_bus.dart"; import "package:photos/events/diff_sync_complete_event.dart"; import "package:photos/events/people_changed_event.dart"; +import "package:photos/models/api/entity/type.dart"; +import "package:photos/services/entity_service.dart"; import "package:photos/services/machine_learning/face_ml/face_detection/detection.dart"; import "package:photos/services/machine_learning/face_ml/face_detection/face_detection_service.dart"; import "package:photos/services/machine_learning/face_ml/face_embedding/face_embedding_service.dart"; @@ -59,6 +61,7 @@ class FaceRecognitionService { return; } _isSyncing = true; + await EntityService.instance.syncEntity(EntityType.cgroup); if (_shouldSyncPeople) { await PersonService.instance.reconcileClusters(); Bus.instance.fire(PeopleChangedEvent(type: PeopleEventType.syncDone)); From a5d01a9ffef40d8ec827af0e5c6ff156419dc1f2 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sun, 29 Sep 2024 09:52:41 +0530 Subject: [PATCH 4/6] [mob] Fix avatar faceID --- .../face_ml/person/person_service.dart | 21 +++++++++++++++++++ .../file_selection_actions_widget.dart | 5 +---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/mobile/lib/services/machine_learning/face_ml/person/person_service.dart b/mobile/lib/services/machine_learning/face_ml/person/person_service.dart index 35b700e1c3..931eaa6a65 100644 --- a/mobile/lib/services/machine_learning/face_ml/person/person_service.dart +++ b/mobile/lib/services/machine_learning/face_ml/person/person_service.dart @@ -8,11 +8,14 @@ import "package:photos/db/ml/db.dart"; import "package:photos/events/people_changed_event.dart"; import "package:photos/extensions/stop_watch.dart"; import "package:photos/models/api/entity/type.dart"; +import "package:photos/models/file/file.dart"; import "package:photos/models/ml/face/person.dart"; import "package:photos/service_locator.dart"; import "package:photos/services/entity_service.dart"; import "package:shared_preferences/shared_preferences.dart"; +import "../../../../models/ml/face/face.dart"; + class PersonService { final EntityService entityService; final MLDataDB faceMLDataDB; @@ -292,6 +295,24 @@ class PersonService { await faceMLDataDB.bulkAssignClusterToPersonID(clusterToPersonID); } + Future updateAvatar(PersonEntity p, EnteFile file) async { + final Face? face = await MLDataDB.instance.getCoverFaceForPerson( + recentFileID: file.uploadedFileID!, + personID: p.remoteID, + ); + if (face == null) { + throw Exception( + "No face found for person ${p.remoteID} in file ${file.uploadedFileID}", + ); + } + + final person = (await getPerson(p.remoteID))!; + final updatedPerson = person.copyWith( + data: person.data.copyWith(avatarFaceId: face.faceID), + ); + await _updatePerson(updatedPerson); + } + Future updateAttributes( String id, { String? name, diff --git a/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart b/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart index d6ec440bb6..5a02fef5c2 100644 --- a/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart +++ b/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart @@ -696,10 +696,7 @@ class _FileSelectionActionsWidgetState Future _setPersonCover() async { final EnteFile file = widget.selectedFiles.files.first; - await PersonService.instance.updateAttributes( - widget.person!.remoteID, - avatarFaceId: file.uploadedFileID.toString(), - ); + await PersonService.instance.updateAvatar(widget.person!, file); widget.selectedFiles.clearAll(); if (mounted) { setState(() => {}); From 026ab8dcc6bd602da0733eb01d2431d23cd8b8cb Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sun, 29 Sep 2024 09:53:15 +0530 Subject: [PATCH 5/6] [mob] Bump version: v0.9.46 --- mobile/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yaml index 2cfa73d84f..cc7fee2f5c 100644 --- a/mobile/pubspec.yaml +++ b/mobile/pubspec.yaml @@ -12,7 +12,7 @@ description: ente photos application # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.9.45+945 +version: 0.9.46+946 publish_to: none environment: From 00e75c0fb2c6d1f530ae519b30505ba5320acdcf Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Sun, 29 Sep 2024 09:54:20 +0530 Subject: [PATCH 6/6] [mob] Lint --- .../machine_learning/face_ml/person/person_service.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mobile/lib/services/machine_learning/face_ml/person/person_service.dart b/mobile/lib/services/machine_learning/face_ml/person/person_service.dart index 931eaa6a65..da46b4b62a 100644 --- a/mobile/lib/services/machine_learning/face_ml/person/person_service.dart +++ b/mobile/lib/services/machine_learning/face_ml/person/person_service.dart @@ -9,13 +9,12 @@ import "package:photos/events/people_changed_event.dart"; import "package:photos/extensions/stop_watch.dart"; import "package:photos/models/api/entity/type.dart"; import "package:photos/models/file/file.dart"; +import 'package:photos/models/ml/face/face.dart'; import "package:photos/models/ml/face/person.dart"; import "package:photos/service_locator.dart"; import "package:photos/services/entity_service.dart"; import "package:shared_preferences/shared_preferences.dart"; -import "../../../../models/ml/face/face.dart"; - class PersonService { final EntityService entityService; final MLDataDB faceMLDataDB;