π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob] Rename method
Neeraj Gupta1e15825617e8
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.dartindex b8bc29e1d5..17546d58cc 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@@ -101,7 +101,7 @@ class FaceRecognitionService {.toSet();_logger.info('starting remote fetch for ${fileIds.length} files');final res =- await RemoteFileMLService.instance.getFilessEmbedding(fileIds);+ await RemoteFileMLService.instance.getFaceEmbedding(fileIds);_logger.info('fetched ${res.mlData.length} embeddings');fetchedCount += res.mlData.length;final List<Face> faces = [];diff --git a/mobile/lib/services/machine_learning/file_ml/remote_fileml_service.dart b/mobile/lib/services/machine_learning/file_ml/remote_fileml_service.dartindex 4bff78a35b..edfd6293e1 100644--- a/mobile/lib/services/machine_learning/file_ml/remote_fileml_service.dart+++ b/mobile/lib/services/machine_learning/file_ml/remote_fileml_service.dart@@ -56,7 +56,7 @@ class RemoteFileMLService {}}- Future<FilesMLDataResponse> getFilessEmbedding(+ Future<FilesMLDataResponse> getFaceEmbedding(Set<int> fileIds,) async {try {@@ -119,68 +119,66 @@ class RemoteFileMLService {},);}-}Future<Map<int, FileMl>> _decryptFileMLComputer(- Map<String, dynamic> args,- ) async {- final result = <int, FileMl>{};- final inputs = args["inputs"] as List<EmbeddingsDecoderInput>;- for (final input in inputs) {- final decryptArgs = <String, dynamic>{};- decryptArgs["source"] =- CryptoUtil.base642bin(input.embedding.encryptedEmbedding);- decryptArgs["key"] = input.decryptionKey;- decryptArgs["header"] =- CryptoUtil.base642bin(input.embedding.decryptionHeader);- final embeddingData = chachaDecryptData(decryptArgs);- final decodedJson = jsonDecode(utf8.decode(embeddingData));- final FileMl decodedEmbedding =- FileMl.fromJson(decodedJson as Map<String, dynamic>);- result[input.embedding.fileID] = decodedEmbedding;- }- return result;+ Map<String, dynamic> args,+) async {+ final result = <int, FileMl>{};+ final inputs = args["inputs"] as List<EmbeddingsDecoderInput>;+ for (final input in inputs) {+ final decryptArgs = <String, dynamic>{};+ decryptArgs["source"] =+ CryptoUtil.base642bin(input.embedding.encryptedEmbedding);+ decryptArgs["key"] = input.decryptionKey;+ decryptArgs["header"] =+ CryptoUtil.base642bin(input.embedding.decryptionHeader);+ final embeddingData = chachaDecryptData(decryptArgs);+ final decodedJson = jsonDecode(utf8.decode(embeddingData));+ final FileMl decodedEmbedding =+ FileMl.fromJson(decodedJson as Map<String, dynamic>);+ result[input.embedding.fileID] = decodedEmbedding;}+ return result;+}bool shouldDiscardRemoteEmbedding(FileMl fileMl) {- if (fileMl.faceEmbedding.version < faceMlVersion) {- debugPrint("Discarding remote embedding for fileID ${fileMl.fileID} "- "because version is ${fileMl.faceEmbedding.version} and we need $faceMlVersion");- return true;- }- // are all landmarks equal?- bool allLandmarksEqual = true;- if (fileMl.faceEmbedding.faces.isEmpty) {- debugPrint("No face for ${fileMl.fileID}");+ if (fileMl.faceEmbedding.version < faceMlVersion) {+ debugPrint("Discarding remote embedding for fileID ${fileMl.fileID} "+ "because version is ${fileMl.faceEmbedding.version} and we need $faceMlVersion");+ 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;}- 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;- break;- }- }- if (allLandmarksEqual) {- debugPrint("Discarding remote embedding for fileID ${fileMl.fileID} "- "because landmarks are equal");- debugPrint(- fileMl.faceEmbedding.faces- .map((e) => e.detection.landmarks.toString())- .toList()- .toString(),- );- return true;- }- if (fileMl.width == null || fileMl.height == null) {- debugPrint("Discarding remote embedding for fileID ${fileMl.fileID} "- "because width is null");- return true;+ if (face.detection.landmarks.any((landmark) => landmark.x != landmark.y)) {+ allLandmarksEqual = false;+ break;}- return false;- }\ No newline at end of file+ }+ if (allLandmarksEqual) {+ debugPrint("Discarding remote embedding for fileID ${fileMl.fileID} "+ "because landmarks are equal");+ debugPrint(+ fileMl.faceEmbedding.faces+ .map((e) => e.detection.landmarks.toString())+ .toList()+ .toString(),+ );+ return true;+ }+ if (fileMl.width == null || fileMl.height == null) {+ debugPrint("Discarding remote embedding for fileID ${fileMl.fileID} "+ "because width is null");+ return true;+ }+ return false;+}