Skip to content

armgit / ente

Public Imported from GitHub
0

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

refactor

Neeraj Guptab03b5806dbed
diff --git a/mobile/lib/db/ml/db_fields.dart b/mobile/lib/db/ml/db_fields.dart
index c6fde65d2f..7a3a9d7631 100644
--- a/mobile/lib/db/ml/db_fields.dart
+++ b/mobile/lib/db/ml/db_fields.dart
@@ -12,7 +12,6 @@ const isSideways = 'is_sideways';
const imageWidth = 'width';
const imageHeight = 'height';
const mlVersionColumn = 'ml_version';
-
const personIdColumn = 'person_id';
const clusterIDColumn = 'cluster_id';
diff --git a/mobile/lib/models/base/id.dart b/mobile/lib/models/base/id.dart
new file mode 100644
index 0000000000..9f226eb90f
--- /dev/null
+++ b/mobile/lib/models/base/id.dart
@@ -0,0 +1,9 @@
+import 'package:nanoid/nanoid.dart';
+
+const enteWhiteListedAlphabet =
+ '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
+const clusterIDLength = 22;
+
+String newClusterID() {
+ return "cluster_${customAlphabet(enteWhiteListedAlphabet, clusterIDLength)}";
+}
diff --git a/mobile/lib/models/nanoids/cluster_id.dart b/mobile/lib/models/nanoids/cluster_id.dart
deleted file mode 100644
index ee2d14013e..0000000000
--- a/mobile/lib/models/nanoids/cluster_id.dart
+++ /dev/null
@@ -1,25 +0,0 @@
-import "package:flutter/foundation.dart";
-import 'package:nanoid/nanoid.dart';
-
-const enteWhiteListedAlphabet =
- '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
-const clusterIDLength = 22;
-
-class ClusterID {
- static String generate() {
- return "cluster_${customAlphabet(enteWhiteListedAlphabet, clusterIDLength)}";
- }
-
- // Validation method
- static bool isValidClusterID(String value) {
- if (value.length != (clusterIDLength + 8)) {
- debugPrint("ClusterID length is not ${clusterIDLength + 8}: $value");
- return false;
- }
- if (value.startsWith("cluster_")) {
- debugPrint("ClusterID doesn't start with _cluster: $value");
- return false;
- }
- return true;
- }
-}
diff --git a/mobile/lib/services/machine_learning/face_ml/face_clustering/face_clustering_service.dart b/mobile/lib/services/machine_learning/face_ml/face_clustering/face_clustering_service.dart
index d33b69c97a..1319c65409 100644
--- a/mobile/lib/services/machine_learning/face_ml/face_clustering/face_clustering_service.dart
+++ b/mobile/lib/services/machine_learning/face_ml/face_clustering/face_clustering_service.dart
@@ -9,7 +9,7 @@ import "package:logging/logging.dart";
import "package:ml_linalg/dtype.dart";
import "package:ml_linalg/vector.dart";
import "package:photos/generated/protos/ente/common/vector.pb.dart";
-import "package:photos/models/nanoids/cluster_id.dart";
+import "package:photos/models/base/id.dart";
import "package:photos/services/machine_learning/face_ml/face_clustering/face_db_info_for_clustering.dart";
import "package:photos/services/machine_learning/face_ml/face_filtering/face_filtering_constants.dart";
import "package:photos/services/machine_learning/ml_result.dart";
@@ -491,11 +491,11 @@ ClusteringResult _runLinearClustering(Map args) {
"[ClusterIsolate] ${DateTime.now()} Processing $totalFaces faces in total in this round ${offset != null ? "on top of ${offset + facesWithClusterID.length} earlier processed faces" : ""}",
);
// set current epoch time as clusterID
- String clusterID = ClusterID.generate();
+ String clusterID = newClusterID();
if (facesWithClusterID.isEmpty) {
// assign a clusterID to the first face
sortedFaceInfos[0].clusterId = clusterID;
- clusterID = ClusterID.generate();
+ clusterID = newClusterID();
}
final stopwatchClustering = Stopwatch()..start();
for (int i = 1; i < totalFaces; i++) {
@@ -539,12 +539,13 @@ ClusteringResult _runLinearClustering(Map args) {
log(
" [ClusterIsolate] [WARNING] ${DateTime.now()} Found new cluster $clusterID",
);
- clusterID = ClusterID.generate();
+ clusterID = newClusterID();
sortedFaceInfos[closestIdx].clusterId = clusterID;
}
sortedFaceInfos[i].clusterId = sortedFaceInfos[closestIdx].clusterId;
} else {
- clusterID = ClusterID.generate();
+ clusterID = newClusterID();
+ ;
sortedFaceInfos[i].clusterId = clusterID;
}
}
@@ -634,7 +635,7 @@ ClusteringResult _runCompleteClustering(Map args) {
"[CompleteClustering] ${DateTime.now()} Processing $totalFaces faces in one single round of complete clustering",
);
- String clusterID = ClusterID.generate();
+ String clusterID = newClusterID();
// Start actual clustering
final Map<String, String> newFaceIdToCluster = {};
@@ -658,12 +659,12 @@ ClusteringResult _runCompleteClustering(Map args) {
if (closestDistance < distanceThreshold) {
if (faceInfos[closestIdx].clusterId == null) {
- clusterID = ClusterID.generate();
+ clusterID = newClusterID();
faceInfos[closestIdx].clusterId = clusterID;
}
faceInfos[i].clusterId = faceInfos[closestIdx].clusterId!;
} else {
- clusterID = ClusterID.generate();
+ clusterID = newClusterID();
faceInfos[i].clusterId = clusterID;
}
}
diff --git a/mobile/lib/ui/viewer/file_details/face_widget.dart b/mobile/lib/ui/viewer/file_details/face_widget.dart
index 04572588c2..58c2338812 100644
--- a/mobile/lib/ui/viewer/file_details/face_widget.dart
+++ b/mobile/lib/ui/viewer/file_details/face_widget.dart
@@ -6,10 +6,10 @@ import "package:flutter/foundation.dart" show kDebugMode;
import "package:flutter/material.dart";
import "package:photos/db/ml/db.dart";
import "package:photos/extensions/stop_watch.dart";
+import "package:photos/models/base/id.dart";
import 'package:photos/models/file/file.dart';
import "package:photos/models/ml/face/face.dart";
import "package:photos/models/ml/face/person.dart";
-import "package:photos/models/nanoids/cluster_id.dart";
import "package:photos/services/machine_learning/face_ml/face_detection/detection.dart";
import "package:photos/services/machine_learning/face_ml/feedback/cluster_feedback.dart";
import "package:photos/services/search_service.dart";
@@ -99,9 +99,9 @@ class _FaceWidgetState extends State<FaceWidget> {
}
// Create new clusterID for the faceID and update DB to assign the faceID to the new clusterID
- final String newClusterID = ClusterID.generate();
+ final String clusterID = newClusterID();
await MLDataDB.instance.updateFaceIdToClusterId(
- {widget.face.faceID: newClusterID},
+ {widget.face.faceID: clusterID},
);
// Push page for the new cluster
@@ -109,7 +109,7 @@ class _FaceWidgetState extends State<FaceWidget> {
MaterialPageRoute(
builder: (context) => ClusterPage(
[widget.file],
- clusterID: newClusterID,
+ clusterID: clusterID,
),
),
);
diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yaml
index 348021f105..a760869744 100644
--- a/mobile/pubspec.yaml
+++ b/mobile/pubspec.yaml
@@ -124,9 +124,9 @@ dependencies:
git: "https://github.com/ente-io/motionphoto.git"
move_to_background: ^1.0.2
nanoid: ^1.0.0
+ native_video_player: ^1.3.1
onnx_dart:
path: plugins/onnx_dart
- native_video_player: ^1.3.1
onnxruntime:
git:
url: https://github.com/ente-io/onnxruntime.git