From f3647df1e9ca7fb0f004c41eeb68e84678e138e0 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Fri, 12 Apr 2024 11:49:40 +0530 Subject: [PATCH] [mob]Improve handling of multiple assignment of same faceID to different clusters --- .../machine_learning/face_ml/person/person_service.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 774267de1c..509862abc8 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 @@ -170,7 +170,13 @@ class PersonService { faceCount += cluster.faces.length; for (var faceId in cluster.faces) { if (faceIdToClusterID.containsKey(faceId)) { - throw Exception("Face $faceId is already assigned to a cluster"); + final otherPersonID = clusterToPersonID[faceIdToClusterID[faceId]!]; + if (otherPersonID != e.id) { + final otherPerson = await getPerson(otherPersonID!); + throw Exception( + "Face $faceId is already assigned to person $otherPersonID (${otherPerson!.data.name}) and person ${e.id} (${personData.name})", + ); + } } faceIdToClusterID[faceId] = cluster.id; }