π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Include rust pipeline in indexing test
laurenspriem186bc20109fd
diff --git a/infra/ml/test/run_ml_parity_tests.sh b/infra/ml/test/run_ml_parity_tests.shindex 0d71323ef2..183ae5f764 100755--- a/infra/ml/test/run_ml_parity_tests.sh+++ b/infra/ml/test/run_ml_parity_tests.sh@@ -23,6 +23,7 @@ RENDER_DETECTION_OVERLAYS=falseREUSE_MOBILE_APPLICATION_BINARY=falsePARALLEL_MOBILE_RUNNERS=trueINCLUDE_PAIRWISE=false+INTERNAL_USER_ROUTE=falseLOCAL_MIRROR_PORT=""LOCAL_MIRROR_PID=""@@ -46,6 +47,7 @@ Flags:--reuse-mobile-application-binary (default: disabled; reuse an existing built mobile binary when available)--no-parallel-mobile-runners (default: disabled; run android/ios runners sequentially)--include-pairwise (default: disabled; include non-ground-truth pairwise platform comparisons)+ --internal (default: disabled; mobile only, run internal-user Rust ML pipeline)EOF}@@ -99,6 +101,10 @@ while (($# > 0)); doINCLUDE_PAIRWISE=trueshift;;+ --internal)+ INTERNAL_USER_ROUTE=true+ shift+ ;;-h|--help)usageexit 0@@ -364,6 +370,7 @@ print_kv "android_build_mode:" "${ML_PARITY_ANDROID_BUILD_MODE:-profile}"print_kv "reuse_mobile_application_binary:" "$REUSE_MOBILE_APPLICATION_BINARY"print_kv "parallel_mobile_runners:" "$PARALLEL_MOBILE_RUNNERS"print_kv "include_pairwise:" "$INCLUDE_PAIRWISE"+print_kv "internal_user_route:" "$INTERNAL_USER_ROUTE"declare -a selected_platforms=()case "$PLATFORMS" in@@ -1443,6 +1450,7 @@ run_mobile_runner() {--no-dds--dart-define=ML_PARITY_MANIFEST_B64="$MANIFEST_B64"--dart-define=ML_PARITY_CODE_REVISION="$CODE_REVISION"+ --dart-define=ML_PARITY_INTERNAL_USER="$INTERNAL_USER_ROUTE")if [[ -z "$resolved_device_id" ]]; thendiff --git a/mobile/apps/photos/integration_test/ml_parity_shared.dart b/mobile/apps/photos/integration_test/ml_parity_shared.dartindex c6940bcd45..af0b6634eb 100644--- a/mobile/apps/photos/integration_test/ml_parity_shared.dart+++ b/mobile/apps/photos/integration_test/ml_parity_shared.dart@@ -21,6 +21,8 @@ const _codeRevision =String.fromEnvironment("ML_PARITY_CODE_REVISION", defaultValue: "local");const _localMirrorBaseUrl =String.fromEnvironment("ML_PARITY_LOCAL_MIRROR_BASE_URL");+const _internalUserRoute =+ bool.fromEnvironment("ML_PARITY_INTERNAL_USER", defaultValue: false);const _localModelMirrorRelativeDir = ".cache/local_model_mirror";const _parityReportDataKey = "ml_parity_results_json";@@ -82,6 +84,7 @@ void runMLParityIntegrationTest({required String expectedPlatform}) {final modelSpecs = _modelSpecs();final loadedModels = await _downloadAndLoadModels(modelSpecs: modelSpecs,+ skipModelLoad: _internalUserRoute,);final runtime = Platform.isAndroid@@ -201,22 +204,26 @@ class _LoadedModels {final List<String> modelNames;final List<int> modelAddresses;final Map<String, String> modelMetadata;+ final Map<String, String> modelPathsBySchema;const _LoadedModels({required this.modelNames,required this.modelAddresses,required this.modelMetadata,+ required this.modelPathsBySchema,});}Future<_LoadedModels> _downloadAndLoadModels({required List<_ModelSpec> modelSpecs,+ required bool skipModelLoad,}) async {await _ensureModelNetworkContext();final modelNames = <String>[];final modelPaths = <String>[];final modelMetadata = <String, String>{};+ final modelPathsBySchema = <String, String>{};for (final modelSpec in modelSpecs) {final (modelName, modelPath) = await modelSpec.model.getModelNameAndPath();@@ -229,11 +236,21 @@ Future<_LoadedModels> _downloadAndLoadModels({modelNames.add(modelName);modelPaths.add(modelFile.path);+ modelPathsBySchema[modelSpec.schemaName] = modelFile.path;final modelSHA256 = await _sha256HexOfFile(modelFile);modelMetadata[modelSpec.schemaName] ="${modelFile.uri.pathSegments.last}:$modelSHA256";}+ if (skipModelLoad) {+ return _LoadedModels(+ modelNames: modelNames,+ modelAddresses: const <int>[],+ modelMetadata: modelMetadata,+ modelPathsBySchema: modelPathsBySchema,+ );+ }+final loadedAddressesRaw = await MLIndexingIsolate.instance.runInIsolate(IsolateOperation.loadIndexingModels,{@@ -255,6 +272,7 @@ Future<_LoadedModels> _downloadAndLoadModels({modelNames: modelNames,modelAddresses: modelAddresses,modelMetadata: modelMetadata,+ modelPathsBySchema: modelPathsBySchema,);}@@ -272,6 +290,9 @@ Future<void> _ensureModelNetworkContext() async {}Future<void> _releaseModels(_LoadedModels loadedModels) async {+ if (loadedModels.modelAddresses.isEmpty) {+ return;+ }await MLIndexingIsolate.instance.runInIsolate(IsolateOperation.releaseIndexingModels,{@@ -455,21 +476,55 @@ Future<MLResult> _analyzeImage({required String filePath,required _LoadedModels loadedModels,}) async {- final faceDetectionAddress = loadedModels.modelAddresses[0];- final faceEmbeddingAddress = loadedModels.modelAddresses[1];- final clipAddress = loadedModels.modelAddresses[2];+ const useRustMl = _internalUserRoute;+ final args = <String, dynamic>{+ "enteFileID": fileID,+ "filePath": filePath,+ "runFaces": true,+ "runClip": true,+ "useRustMl": useRustMl,+ };- final resultJSONString = await MLIndexingIsolate.instance.runInIsolate(- IsolateOperation.analyzeImage,- {- "enteFileID": fileID,- "filePath": filePath,- "runFaces": true,- "runClip": true,+ if (useRustMl) {+ final faceDetectionModelPath =+ loadedModels.modelPathsBySchema["face_detection"];+ final faceEmbeddingModelPath =+ loadedModels.modelPathsBySchema["face_embedding"];+ final clipImageModelPath = loadedModels.modelPathsBySchema["clip"];+ if (faceDetectionModelPath == null ||+ faceEmbeddingModelPath == null ||+ clipImageModelPath == null) {+ throw StateError(+ "Missing model paths for Rust ML parity route: face_detection/face_embedding/clip",+ );+ }+ args.addAll({+ "faceDetectionModelPath": faceDetectionModelPath,+ "faceEmbeddingModelPath": faceEmbeddingModelPath,+ "clipImageModelPath": clipImageModelPath,+ "preferCoreml": Platform.isIOS,+ "preferNnapi": Platform.isAndroid,+ "allowCpuFallback": true,+ });+ } else {+ if (loadedModels.modelAddresses.length < 3) {+ throw StateError(+ "Missing loaded model addresses for static parity route",+ );+ }+ final faceDetectionAddress = loadedModels.modelAddresses[0];+ final faceEmbeddingAddress = loadedModels.modelAddresses[1];+ final clipAddress = loadedModels.modelAddresses[2];+ args.addAll({"faceDetectionAddress": faceDetectionAddress,"faceEmbeddingAddress": faceEmbeddingAddress,"clipImageAddress": clipAddress,- },+ });+ }++ final resultJSONString = await MLIndexingIsolate.instance.runInIsolate(+ IsolateOperation.analyzeImage,+ args,) as String;return MLResult.fromJsonString(resultJSONString);}