Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Simplify face embedding service

laurenspriemb625bd1afcc1
diff --git a/mobile/lib/services/machine_learning/face_ml/face_embedding/face_embedding_service.dart b/mobile/lib/services/machine_learning/face_ml/face_embedding/face_embedding_service.dart
index acbac0262c..b2f0b2d9d1 100644
--- a/mobile/lib/services/machine_learning/face_ml/face_embedding/face_embedding_service.dart
+++ b/mobile/lib/services/machine_learning/face_ml/face_embedding/face_embedding_service.dart
@@ -35,21 +35,21 @@ class FaceEmbeddingService extends MlModel {
static Future<List<List<double>>> predict(
Float32List input,
- int sessionAddress, {
- bool useEntePlugin = false,
- }) async {
- if (!useEntePlugin) {
+ int sessionAddress,
+ ) async {
+ if (!MlModel.usePlatformPlugin) {
assert(sessionAddress != 0 && sessionAddress != -1);
}
try {
- if (useEntePlugin) {
- return await _runEntePlugin(input);
+ if (MlModel.usePlatformPlugin) {
+ return await _runPlatformPluginPredict(input);
} else {
return _runFFIBasedPredict(input, sessionAddress);
}
} catch (e) {
_logger.info(
- 'MobileFaceNet (entePlugin: $useEntePlugin)Error while running inference: $e',);
+ 'MobileFaceNet (PlatformPlugin: $MlModel.usePlatformPlugin)Error while running inference: $e',
+ );
throw MobileFaceNetInterpreterRunException();
}
}
@@ -82,7 +82,7 @@ class FaceEmbeddingService extends MlModel {
return embeddings;
}
- static Future<List<List<double>>> _runEntePlugin(
+ static Future<List<List<double>>> _runPlatformPluginPredict(
Float32List inputImageList,
) async {
final stopwatch = Stopwatch()..start();
@@ -102,7 +102,7 @@ class FaceEmbeddingService extends MlModel {
normalizeEmbedding(embedding);
}
_logger.info(
- 'MobileFaceNetEntePlugin interpreter.run is finished, in ${stopwatch.elapsedMilliseconds}ms',
+ 'MobileFaceNetPlatformPlugin interpreter.run is finished, in ${stopwatch.elapsedMilliseconds}ms',
);
return embeddings;
}
diff --git a/mobile/lib/services/machine_learning/face_ml/face_recognition_service.dart b/mobile/lib/services/machine_learning/face_ml/face_recognition_service.dart
index 69e55e209c..3c00620873 100644
--- a/mobile/lib/services/machine_learning/face_ml/face_recognition_service.dart
+++ b/mobile/lib/services/machine_learning/face_ml/face_recognition_service.dart
@@ -1,6 +1,5 @@
import "dart:async" show unawaited;
import "dart:developer" as dev show log;
-import "dart:io";
import "dart:typed_data" show ByteData, Float32List;
import "dart:ui" show Image;
@@ -327,7 +326,6 @@ class FaceRecognitionService {
final List<List<double>> embeddings = await FaceEmbeddingService.predict(
facesList,
interpreterAddress,
- useEntePlugin: Platform.isAndroid,
);
// Store the results