Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] SemanticSearchService minor changes

laurenspriem9232cd150bf3
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.dart
index 1cc99073c2..dd5f52f894 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
@@ -61,6 +61,7 @@ class SemanticSearchService {
await EmbeddingsDB.instance.init();
await _loadImageEmbeddings();
Bus.instance.on<EmbeddingUpdatedEvent>().listen((event) {
+ if (!_hasInitialized) return;
_embeddingLoaderDebouncer.run(() async {
await _loadImageEmbeddings();
});
@@ -74,6 +75,13 @@ class SemanticSearchService {
});
}
+ Future<void> dispose() async {
+ if (!_hasInitialized) return;
+ _hasInitialized = false;
+ await ClipTextEncoder.instance.release();
+ _cachedImageEmbeddings.clear();
+ }
+
Future<void> sync() async {
if (_isSyncing) {
return;
@@ -90,6 +98,11 @@ class SemanticSearchService {
_cachedImageEmbeddings.isNotEmpty;
}
+ bool bothClipModelsLoaded() {
+ return ClipImageEncoder.instance.isInitialized &&
+ ClipTextEncoder.instance.isInitialized;
+ }
+
// searchScreenQuery should only be used for the user initiate query on the search screen.
// If there are multiple call tho this method, then for all the calls, the result will be the same as the last query.
Future<(String, List<EnteFile>)> searchScreenQuery(String query) async {