[mob] Rename face embedding service
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
class FaceEmbeddingOptions {
|
||||
final int inputWidth;
|
||||
final int inputHeight;
|
||||
final int embeddingLength;
|
||||
final int numChannels;
|
||||
final bool preWhiten;
|
||||
|
||||
FaceEmbeddingOptions({
|
||||
required this.inputWidth,
|
||||
required this.inputHeight,
|
||||
this.embeddingLength = 192,
|
||||
this.numChannels = 3,
|
||||
this.preWhiten = false,
|
||||
});
|
||||
}
|
||||
@@ -10,8 +10,8 @@ import "package:photos/services/remote_assets_service.dart";
|
||||
import "package:photos/utils/image_ml_isolate.dart";
|
||||
import "package:synchronized/synchronized.dart";
|
||||
|
||||
/// This class is responsible for running the face embedding model on ONNX runtime, and can be accessed through the singleton instance [FaceEmbeddingOnnx.instance].
|
||||
class FaceEmbeddingOnnx {
|
||||
/// This class is responsible for running the face embedding model on ONNX runtime, and can be accessed through the singleton instance [FaceEmbeddingService.instance].
|
||||
class FaceEmbeddingService {
|
||||
static const kModelBucketEndpoint = "https://models.ente.io/";
|
||||
static const kRemoteBucketModelPath = "mobilefacenet_opset15.onnx";
|
||||
static const modelRemotePath = kModelBucketEndpoint + kRemoteBucketModelPath;
|
||||
@@ -31,7 +31,7 @@ class FaceEmbeddingOnnx {
|
||||
final _computerLock = Lock();
|
||||
|
||||
// singleton pattern
|
||||
FaceEmbeddingOnnx._privateConstructor();
|
||||
FaceEmbeddingService._privateConstructor();
|
||||
|
||||
/// Use this instance to access the FaceEmbedding service. Make sure to call `init()` before using it.
|
||||
/// e.g. `await FaceEmbedding.instance.init();`
|
||||
@@ -39,8 +39,8 @@ class FaceEmbeddingOnnx {
|
||||
/// Then you can use `predict()` to get the embedding of a face, so `FaceEmbedding.instance.predict(imageData)`
|
||||
///
|
||||
/// config options: faceEmbeddingEnte
|
||||
static final instance = FaceEmbeddingOnnx._privateConstructor();
|
||||
factory FaceEmbeddingOnnx() => instance;
|
||||
static final instance = FaceEmbeddingService._privateConstructor();
|
||||
factory FaceEmbeddingService() => instance;
|
||||
|
||||
/// Check if the interpreter is initialized, if not initialize it with `loadModel()`
|
||||
Future<void> init() async {
|
||||
@@ -31,7 +31,7 @@ import 'package:photos/services/machine_learning/face_ml/face_detection/detectio
|
||||
import 'package:photos/services/machine_learning/face_ml/face_detection/yolov5face/onnx_face_detection.dart';
|
||||
import 'package:photos/services/machine_learning/face_ml/face_detection/yolov5face/yolo_face_detection_exceptions.dart';
|
||||
import 'package:photos/services/machine_learning/face_ml/face_embedding/face_embedding_exceptions.dart';
|
||||
import 'package:photos/services/machine_learning/face_ml/face_embedding/onnx_face_embedding.dart';
|
||||
import 'package:photos/services/machine_learning/face_ml/face_embedding/face_embedding_service.dart';
|
||||
import 'package:photos/services/machine_learning/face_ml/face_filtering/face_filtering_constants.dart';
|
||||
import 'package:photos/services/machine_learning/face_ml/face_ml_exceptions.dart';
|
||||
import 'package:photos/services/machine_learning/face_ml/face_ml_result.dart';
|
||||
@@ -102,7 +102,7 @@ class FaceMlService {
|
||||
}
|
||||
}
|
||||
try {
|
||||
await FaceEmbeddingOnnx.instance.init();
|
||||
await FaceEmbeddingService.instance.init();
|
||||
} catch (e, s) {
|
||||
_logger.severe("Could not initialize mobilefacenet", e, s);
|
||||
}
|
||||
@@ -152,7 +152,7 @@ class FaceMlService {
|
||||
_logger.severe("Could not dispose image ml isolate", e, s);
|
||||
}
|
||||
try {
|
||||
await FaceEmbeddingOnnx.instance.release();
|
||||
await FaceEmbeddingService.instance.release();
|
||||
} catch (e, s) {
|
||||
_logger.severe("Could not dispose mobilefacenet", e, s);
|
||||
}
|
||||
@@ -895,7 +895,8 @@ class FaceMlService {
|
||||
"filePath": filePath,
|
||||
"faceDetectionAddress":
|
||||
YoloOnnxFaceDetection.instance.sessionAddress,
|
||||
"faceEmbeddingAddress": FaceEmbeddingOnnx.instance.sessionAddress,
|
||||
"faceEmbeddingAddress":
|
||||
FaceEmbeddingService.instance.sessionAddress,
|
||||
}
|
||||
),
|
||||
) as String?;
|
||||
@@ -1185,7 +1186,7 @@ class FaceMlService {
|
||||
try {
|
||||
// Get the embedding of the faces
|
||||
final List<List<double>> embeddings =
|
||||
await FaceEmbeddingOnnx.instance.predictInComputer(facesList);
|
||||
await FaceEmbeddingService.instance.predictInComputer(facesList);
|
||||
|
||||
// Add the embeddings to the resultBuilder
|
||||
if (resultBuilder != null) {
|
||||
@@ -1218,7 +1219,7 @@ class FaceMlService {
|
||||
try {
|
||||
// Get the embedding of the faces
|
||||
final List<List<double>> embeddings =
|
||||
await FaceEmbeddingOnnx.predictSync(facesList, interpreterAddress);
|
||||
await FaceEmbeddingService.predictSync(facesList, interpreterAddress);
|
||||
|
||||
// Add the embeddings to the resultBuilder
|
||||
if (resultBuilder != null) {
|
||||
|
||||
Reference in New Issue
Block a user