π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
invalide clip text on onnx runtime corruption also
laurenspriem227f7f853618
diff --git a/mobile/apps/photos/lib/services/machine_learning/ml_computer.dart b/mobile/apps/photos/lib/services/machine_learning/ml_computer.dartindex 9600e4b6b0..a47a03c86e 100644--- a/mobile/apps/photos/lib/services/machine_learning/ml_computer.dart+++ b/mobile/apps/photos/lib/services/machine_learning/ml_computer.dart@@ -10,6 +10,7 @@ import "package:photos/models/ml/vector.dart";import "package:photos/service_locator.dart"show flagService, isLocalGalleryMode;import "package:photos/services/machine_learning/ml_constants.dart";+import "package:photos/services/machine_learning/ml_model_download_service.dart";import "package:photos/services/machine_learning/semantic_search/clip/clip_text_encoder.dart";import "package:photos/services/machine_learning/semantic_search/query_result.dart";import "package:photos/services/remote_assets_service.dart";@@ -91,7 +92,7 @@ class MLComputer extends SuperIsolate {"RustMLMissingModelPath: Missing required model path: clipTextVocabPath",);}- final textEmbedding = await runInIsolate(IsolateOperation.runClipText, {+ final isolateResult = await runInIsolate(IsolateOperation.runClipText, {"text": query,"useRustMl": useRustMl,if (useRustMl) ...{@@ -104,7 +105,15 @@ class MLComputer extends SuperIsolate {} else ...{"address": ClipTextEncoder.instance.sessionAddress,},- }) as List<double>;+ });+ if (isolateResult is RustCorruptModelCacheDeletedException) {+ _clipTextModelPath = null;+ MLModelDownloadService.instance.invalidateModelDownloadCache(+ includeNonIndexingModels: true,+ );+ throw isolateResult;+ }+ final textEmbedding = isolateResult as List<double>;return textEmbedding;} on WiFiUnavailableError catch (e, s) {_logger.warning(@@ -113,6 +122,11 @@ class MLComputer extends SuperIsolate {s,);rethrow;+ } on RustCorruptModelCacheDeletedException catch (e) {+ _logger.warning(+ "Deleted corrupt Rust CLIP text model cache at ${e.modelPath}",+ );+ rethrow;} catch (e, s) {_logger.severe("Could not run clip text in isolate", e, s);rethrow;diff --git a/mobile/apps/photos/lib/utils/isolate/isolate_operations.dart b/mobile/apps/photos/lib/utils/isolate/isolate_operations.dartindex a3702e64e9..5085740cde 100644--- a/mobile/apps/photos/lib/utils/isolate/isolate_operations.dart+++ b/mobile/apps/photos/lib/utils/isolate/isolate_operations.dart@@ -261,19 +261,28 @@ Future<dynamic> isolateFunction();}- final result = await rust_ml.runClipTextRust(- req: rust_ml.RunClipTextRequest(- text: text,- modelPath: clipTextModelPath,- vocabPath: clipTextVocabPath,- providerPolicy: rust_ml.RustExecutionProviderPolicy(- preferCoreml: args["preferCoreml"] as bool? ?? true,- preferNnapi: args["preferNnapi"] as bool? ?? true,- preferXnnpack: args["preferXnnpack"] as bool? ?? false,- allowCpuFallback: args["allowCpuFallback"] as bool? ?? true,+ final rust_ml.RunClipTextResult result;+ try {+ result = await rust_ml.runClipTextRust(+ req: rust_ml.RunClipTextRequest(+ text: text,+ modelPath: clipTextModelPath,+ vocabPath: clipTextVocabPath,+ providerPolicy: rust_ml.RustExecutionProviderPolicy(+ preferCoreml: args["preferCoreml"] as bool? ?? true,+ preferNnapi: args["preferNnapi"] as bool? ?? true,+ preferXnnpack: args["preferXnnpack"] as bool? ?? false,+ allowCpuFallback: args["allowCpuFallback"] as bool? ?? true,+ ),),- ),- );+ );+ } on rust_ml.RustMlError_CorruptModel catch (e) {+ final file = File(e.field0);+ if (await file.exists()) {+ await file.delete();+ }+ return RustCorruptModelCacheDeletedException(e.field0);+ }return List<double>.from(result.embedding, growable: false);/// MLComputerdiff --git a/mobile/apps/photos/rust/src/api/ml_indexing_api.rs b/mobile/apps/photos/rust/src/api/ml_indexing_api.rsindex 9424695c58..f44f9d9fcc 100644--- a/mobile/apps/photos/rust/src/api/ml_indexing_api.rs+++ b/mobile/apps/photos/rust/src/api/ml_indexing_api.rs@@ -185,7 +185,7 @@ pub fn analyze_image_rust(req: AnalyzeImageRequest) -> Result<AnalyzeImageResult.map_err(RustMlError::from)}-pub fn run_clip_text_rust(req: RunClipTextRequest) -> Result<RunClipTextResult, String> {+pub fn run_clip_text_rust(req: RunClipTextRequest) -> Result<RunClipTextResult, RustMlError> {let shared_req = shared_indexing::RunClipTextRequest {text: req.text,model_path: req.model_path,@@ -201,7 +201,7 @@ pub fn run_clip_text_rust(req: RunClipTextRequest) -> Result<RunClipTextResult,.map(|value| value as f64).collect(),})- .map_err(|e| e.to_string())+ .map_err(RustMlError::from)}pub fn tokenize_clip_text_rust(text: String, vocab_path: String) -> Result<Vec<i32>, String> {