Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Simplify ClipImage

laurenspriem3abf215f8c6d
diff --git a/mobile/lib/services/machine_learning/semantic_search/clip/clip_image_encoder.dart b/mobile/lib/services/machine_learning/semantic_search/clip/clip_image_encoder.dart
index ba68ed1dc7..ae00eea239 100644
--- a/mobile/lib/services/machine_learning/semantic_search/clip/clip_image_encoder.dart
+++ b/mobile/lib/services/machine_learning/semantic_search/clip/clip_image_encoder.dart
@@ -31,20 +31,14 @@ class ClipImageEncoder extends MlModel {
static Future<List<double>> predict(
Image image,
ByteData imageByteData,
- int sessionAddress, {
- bool useEntePlugin = false,
- }) async {
- final w = EnteWatch("ClipImageEncoder.predict")..start();
+ int sessionAddress,
+ ) async {
final inputList = await preprocessImageClip(image, imageByteData);
- w.log("preprocessImageClip");
- if (useEntePlugin) {
- final result = await _runEntePlugin(inputList);
- w.stopWithLog("done");
- return result;
+ if (MlModel.usePlatformPlugin) {
+ return await _runPlatformPluginPredict(inputList);
+ } else {
+ return _runFFIBasedPredict(inputList, sessionAddress);
}
- final result = _runFFIBasedPredict(inputList, sessionAddress);
- w.stopWithLog("done");
- return result;
}
static List<double> _runFFIBasedPredict(
@@ -64,7 +58,7 @@ class ClipImageEncoder extends MlModel {
return embedding;
}
- static Future<List<double>> _runEntePlugin(
+ static Future<List<double>> _runPlatformPluginPredict(
Float32List inputImageList,
) async {
final w = EnteWatch("ClipImageEncoder._runEntePlugin")..start();
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 af20abb9e0..1c196314b0 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
@@ -300,14 +300,12 @@ class SemanticSearchService {
int enteFileID,
Image image,
ByteData imageByteData,
- int clipImageAddress, {
- bool useEntePlugin = false,
- }) async {
+ int clipImageAddress,
+ ) async {
final embedding = await ClipImageEncoder.predict(
image,
imageByteData,
clipImageAddress,
- useEntePlugin: useEntePlugin,
);
final clipResult = ClipResult(fileID: enteFileID, embedding: embedding);
diff --git a/mobile/lib/utils/ml_util.dart b/mobile/lib/utils/ml_util.dart
index dfc18121a5..883c871e58 100644
--- a/mobile/lib/utils/ml_util.dart
+++ b/mobile/lib/utils/ml_util.dart
@@ -1,4 +1,4 @@
-import "dart:io" show File, Platform;
+import "dart:io" show File;
import "dart:math" as math show sqrt, min, max;
import "dart:typed_data" show ByteData;
@@ -300,7 +300,6 @@ Future<MLResult> analyzeImageStatic(Map args) async {
image,
imageByteData,
clipImageAddress,
- useEntePlugin: Platform.isAndroid,
);
result.clip = clipResult;
}