Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] constructor

laurenspriemed2978bf5572
diff --git a/mobile/lib/models/ml/face/face.dart b/mobile/lib/models/ml/face/face.dart
index 455938868b..4a794baff5 100644
--- a/mobile/lib/models/ml/face/face.dart
+++ b/mobile/lib/models/ml/face/face.dart
@@ -1,4 +1,7 @@
+import "package:photos/models/ml/face/box.dart";
import "package:photos/models/ml/face/detection.dart";
+import "package:photos/models/ml/face/dimension.dart";
+import "package:photos/models/ml/face/landmark.dart";
import 'package:photos/services/machine_learning/face_ml/face_filtering/face_filtering_constants.dart';
import "package:photos/services/machine_learning/ml_result.dart";
@@ -42,6 +45,41 @@ class Face {
this.fileInfo,
});
+ factory Face.fromFaceResult(
+ FaceResult faceResult,
+ int fileID,
+ Dimensions decodedDimensions,
+ ) {
+ final detection = Detection(
+ box: FaceBox(
+ x: faceResult.detection.xMinBox,
+ y: faceResult.detection.yMinBox,
+ width: faceResult.detection.width,
+ height: faceResult.detection.height,
+ ),
+ landmarks: faceResult.detection.allKeypoints
+ .map(
+ (keypoint) => Landmark(
+ x: keypoint[0],
+ y: keypoint[1],
+ ),
+ )
+ .toList(),
+ );
+ return Face(
+ faceResult.faceId,
+ fileID,
+ faceResult.embedding,
+ faceResult.detection.score,
+ detection,
+ faceResult.blurValue,
+ fileInfo: FileInfo(
+ imageHeight: decodedDimensions.height,
+ imageWidth: decodedDimensions.width,
+ ),
+ );
+ }
+
factory Face.empty(int fileID, {bool error = false}) {
return Face(
"${fileID}_0_0_0_0",
diff --git a/mobile/lib/services/machine_learning/ml_service.dart b/mobile/lib/services/machine_learning/ml_service.dart
index 8c7060d2c7..ccede73cc9 100644
--- a/mobile/lib/services/machine_learning/ml_service.dart
+++ b/mobile/lib/services/machine_learning/ml_service.dart
@@ -11,10 +11,7 @@ import "package:photos/db/files_db.dart";
import "package:photos/db/ml/db.dart";
import "package:photos/events/machine_learning_control_event.dart";
import "package:photos/events/people_changed_event.dart";
-import "package:photos/models/ml/face/box.dart";
-import "package:photos/models/ml/face/detection.dart" as face_detection;
import "package:photos/models/ml/face/face.dart";
-import "package:photos/models/ml/face/landmark.dart";
import "package:photos/models/ml/ml_versions.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/filedata/filedata_service.dart";
@@ -416,35 +413,11 @@ class MLService {
);
}
for (int i = 0; i < result.faces!.length; ++i) {
- final FaceResult faceRes = result.faces![i];
- final detection = face_detection.Detection(
- box: FaceBox(
- x: faceRes.detection.xMinBox,
- y: faceRes.detection.yMinBox,
- width: faceRes.detection.width,
- height: faceRes.detection.height,
- ),
- landmarks: faceRes.detection.allKeypoints
- .map(
- (keypoint) => Landmark(
- x: keypoint[0],
- y: keypoint[1],
- ),
- )
- .toList(),
- );
faces.add(
- Face(
- faceRes.faceId,
+ Face.fromFaceResult(
+ result.faces![i],
result.fileId,
- faceRes.embedding,
- faceRes.detection.score,
- detection,
- faceRes.blurValue,
- fileInfo: FileInfo(
- imageHeight: result.decodedImageSize.height,
- imageWidth: result.decodedImageSize.width,
- ),
+ result.decodedImageSize,
),
);
}