From e82cda1e82b760c811dd88ac07d7e4e5e129c48a Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Wed, 10 Apr 2024 10:10:53 +0530 Subject: [PATCH] [mob] Fix bug in discarding remote embedding --- .../face_ml/face_ml_service.dart | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart b/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart index 53c4bac486..d32a7f2bb0 100644 --- a/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart +++ b/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart @@ -470,9 +470,22 @@ class FaceMlService { "because version is ${fileMl.faceEmbedding.version} and we need $faceMlVersion"); return true; } + if (fileMl.faceEmbedding.error ?? false) { + debugPrint("Discarding remote embedding for fileID ${fileMl.fileID} " + "because error is true"); + return true; + } // are all landmarks equal? bool allLandmarksEqual = true; + if (fileMl.faceEmbedding.faces.isEmpty) { + debugPrint("No face for ${fileMl.fileID}"); + allLandmarksEqual = false; + } for (final face in fileMl.faceEmbedding.faces) { + if (face.detection.landmarks.isEmpty) { + allLandmarksEqual = false; + break; + } if (face.detection.landmarks .any((landmark) => landmark.x != landmark.y)) { allLandmarksEqual = false; @@ -482,6 +495,12 @@ class FaceMlService { if (allLandmarksEqual) { debugPrint("Discarding remote embedding for fileID ${fileMl.fileID} " "because landmarks are not equal"); + debugPrint( + fileMl.faceEmbedding.faces + .map((e) => e.detection.landmarks) + .toList() + .toString(), + ); return true; } if (fileMl.width == null || fileMl.height == null) {