diff --git a/mobile/lib/face/db.dart b/mobile/lib/face/db.dart index 7f1053d7f..95eb0ac15 100644 --- a/mobile/lib/face/db.dart +++ b/mobile/lib/face/db.dart @@ -215,7 +215,7 @@ class FaceMLDataDB { final List fileId = [recentFileID]; int? avatarFileId; if (avatarFaceId != null) { - avatarFileId = int.tryParse(avatarFaceId!.split('_')[0]); + avatarFileId = int.tryParse(avatarFaceId.split('_')[0]); if (avatarFileId != null) { fileId.add(avatarFileId); } diff --git a/mobile/lib/services/machine_learning/face_ml/face_clustering/clusters_mapping.dart b/mobile/lib/services/machine_learning/face_ml/face_clustering/clusters_mapping.dart new file mode 100644 index 000000000..77be47e2b --- /dev/null +++ b/mobile/lib/services/machine_learning/face_ml/face_clustering/clusters_mapping.dart @@ -0,0 +1,22 @@ +import "package:photos/face/model/person.dart"; + +enum MappingSource { + local, + remote, +} + +class ClustersMapping { + final Map> fileIDToClusterIDs; + final Map clusterToPersonID; + // personIDToPerson is a map of personID to PersonEntity, and it's same for + // both local and remote sources + final Map personIDToPerson; + final MappingSource source; + + ClustersMapping({ + required this.fileIDToClusterIDs, + required this.clusterToPersonID, + required this.personIDToPerson, + required this.source, + }); +} diff --git a/mobile/lib/services/machine_learning/face_ml/face_clustering/linear_clustering_service.dart b/mobile/lib/services/machine_learning/face_ml/face_clustering/linear_clustering_service.dart index 86b747551..80ec060aa 100644 --- a/mobile/lib/services/machine_learning/face_ml/face_clustering/linear_clustering_service.dart +++ b/mobile/lib/services/machine_learning/face_ml/face_clustering/linear_clustering_service.dart @@ -503,7 +503,7 @@ class FaceClustering { "[ClusterIsolate] ${DateTime.now()} Copied to isolate ${x.length} faces", ); - DBSCAN dbscan = DBSCAN( + final DBSCAN dbscan = DBSCAN( epsilon: eps, minPoints: minPts, distanceMeasure: cosineDistForNormVectors, 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 811eec3ac..a31f31dd3 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 @@ -49,11 +49,11 @@ class PersonService { Future> getPersonsMap() async { final entities = await entityService.getEntities(EntityType.person); final Map map = {}; - entities.forEach((e) { + for (var e in entities) { final person = PersonEntity(e.id, PersonData.fromJson(json.decode(e.data))); map[person.remoteID] = person; - }); + } return map; } diff --git a/mobile/lib/services/search_service.dart b/mobile/lib/services/search_service.dart index 06a6dc5e6..c597c2219 100644 --- a/mobile/lib/services/search_service.dart +++ b/mobile/lib/services/search_service.dart @@ -745,7 +745,6 @@ class SearchService { final clusterIDToPerson = await FaceMLDataDB.instance.getClusterIdToPerson(personIdToPerson); - debugPrint("building result"); final List facesResult = []; final Map> clusterIdToFiles = {}; final Map> personIdToFiles = {}; diff --git a/mobile/lib/ui/viewer/search/result/person_face_widget.dart b/mobile/lib/ui/viewer/search/result/person_face_widget.dart index fe2732c4e..36f5db800 100644 --- a/mobile/lib/ui/viewer/search/result/person_face_widget.dart +++ b/mobile/lib/ui/viewer/search/result/person_face_widget.dart @@ -26,8 +26,10 @@ class PersonFaceWidget extends StatelessWidget { this.personId, this.clusterID, Key? key, - }) : assert(personId != null || clusterID != null, - "PersonFaceWidget requires either personId or clusterID to be non-null"), + }) : assert( + personId != null || clusterID != null, + "PersonFaceWidget requires either personId or clusterID to be non-null", + ), super(key: key); @override @@ -85,7 +87,7 @@ class PersonFaceWidget extends StatelessWidget { Future _getFace() async { String? personAvatarFaceID; if (personId != null) { - PersonEntity? personEntity = + final PersonEntity? personEntity = await PersonService.instance.getPerson(personId!); if (personEntity != null) { personAvatarFaceID = personEntity.data.avatarFaceId;