From 2b147c1a87de1acae5c8098605722b82c6f3d480 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:34:38 +0530 Subject: [PATCH] [mob] Minor improvements for ml sync --- mobile/lib/models/ml/face/face.dart | 2 +- .../face_ml/person/person_service.dart | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/mobile/lib/models/ml/face/face.dart b/mobile/lib/models/ml/face/face.dart index 2aeeb7aff3..75c3549c41 100644 --- a/mobile/lib/models/ml/face/face.dart +++ b/mobile/lib/models/ml/face/face.dart @@ -98,7 +98,7 @@ class Face { faceID, fileID, parseAsDoubleList(json['embedding'] as List), - json['score'] as double, + parseIntOrDoubleAsDouble(json['score'])!, Detection.fromJson(json['detection'] as Map), // high value means t parseIntOrDoubleAsDouble(json['blur']) ?? kLapacianDefault, 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 da46b4b62a..31ccb54960 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 @@ -113,13 +113,12 @@ class PersonService { PersonData personData, Map> dbPersonCluster, ) { - bool result = false; if ((personData.assigned?.length ?? 0) != dbPersonCluster.length) { log( "Person ${personData.name} has ${personData.assigned?.length} clusters, but ${dbPersonCluster.length} clusters found in DB", name: "PersonService", ); - result = true; + return true; } else { for (ClusterInfo info in personData.assigned!) { final dbCluster = dbPersonCluster[info.id]; @@ -128,15 +127,14 @@ class PersonService { "Cluster ${info.id} not found in DB for person ${personData.name}", name: "PersonService", ); - result = true; - continue; + return true; } if (info.faces.length != dbCluster.length) { log( "Cluster ${info.id} has ${info.faces.length} faces, but ${dbCluster.length} faces found in DB", name: "PersonService", ); - result = true; + return true; } for (var faceId in info.faces) { if (!dbCluster.contains(faceId)) { @@ -144,12 +142,12 @@ class PersonService { "Face $faceId not found in cluster ${info.id} for person ${personData.name}", name: "PersonService", ); - result = true; + return true; } } } } - return result; + return false; } Future addPerson(