π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob] Fix text embedding
Neeraj Gupta56b019aa1e76
diff --git a/mobile/lib/services/machine_learning/semantic_search/semantic_search_service.dart b/mobile/lib/services/machine_learning/semantic_search/semantic_search_service.dartindex 5d6475bb55..3768e034f5 100644--- a/mobile/lib/services/machine_learning/semantic_search/semantic_search_service.dart+++ b/mobile/lib/services/machine_learning/semantic_search/semantic_search_service.dart@@ -1,5 +1,6 @@import "dart:async";import "dart:developer" as dev show log;+import "dart:io";import "dart:math" show min;import "dart:typed_data" show ByteData;import "dart:ui" show Image;@@ -260,8 +261,8 @@ class SemanticSearchService {Future<void> _loadTextModel() async {_logger.info("Initializing ML framework");try {- await ClipTextEncoder.instance.loadModel();- await ClipTextEncoder.instance.loadModel(useEntePlugin: true);+ await ClipTextEncoder.instance+ .loadModel(useEntePlugin: Platform.isAndroid);_textModelIsLoaded = true;} catch (e, s) {_logger.severe("Clip text loading failed", e, s);@@ -296,16 +297,21 @@ class SemanticSearchService {}try {final int clipAddress = ClipTextEncoder.instance.sessionAddress;- // final textEmbedding = await _computer.compute(- // ClipTextEncoder.infer,- // param: {- // "text": query,- // "address": clipAddress,- // },- // ) as List<double>;- final textEmbedding = await ClipTextEncoder.infer(- {"text": query, "address": clipAddress},- );+ late final List<double> textEmbedding;+ if (Platform.isAndroid) {+ textEmbedding = await ClipTextEncoder.infer(+ {"text": query, "address": clipAddress},+ );+ } else {+ textEmbedding = await _computer.compute(+ ClipTextEncoder.infer,+ param: {+ "text": query,+ "address": clipAddress,+ },+ ) as List<double>;+ }+_queryCache.put(query, textEmbedding);return textEmbedding;} catch (e) {