Skip to content

armgit / ente

Public Imported from GitHub
0

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

Switch to nano_id for clusterIDs

Neeraj Guptaffd9e2e06cd8
diff --git a/mobile/lib/face/db.dart b/mobile/lib/face/db.dart
index 81c896e164..cdc014f86e 100644
--- a/mobile/lib/face/db.dart
+++ b/mobile/lib/face/db.dart
@@ -28,7 +28,7 @@ import 'package:sqlite_async/sqlite_async.dart';
class FaceMLDataDB {
static final Logger _logger = Logger("FaceMLDataDB");
- static const _databaseName = "ente.face_ml_db.db";
+ static const _databaseName = "ente.face_ml_db_v2.db";
// static const _databaseVersion = 1;
FaceMLDataDB._privateConstructor();
@@ -136,7 +136,7 @@ class FaceMLDataDB {
}
Future<void> updateFaceIdToClusterId(
- Map<String, int> faceIDToClusterID,
+ Map<String, String> faceIDToClusterID,
) async {
final db = await instance.asyncDB;
const batchSize = 500;
@@ -185,43 +185,43 @@ class FaceMLDataDB {
return maps.first['count'] as int;
}
- Future<Map<int, int>> clusterIdToFaceCount() async {
+ Future<Map<String, int>> clusterIdToFaceCount() async {
final db = await instance.asyncDB;
final List<Map<String, dynamic>> maps = await db.getAll(
'SELECT $fcClusterID, COUNT(*) as count FROM $faceClustersTable where $fcClusterID IS NOT NULL GROUP BY $fcClusterID ',
);
- final Map<int, int> result = {};
+ final Map<String, int> result = {};
for (final map in maps) {
- result[map[fcClusterID] as int] = map['count'] as int;
+ result[map[fcClusterID] as String] = map['count'] as int;
}
return result;
}
- Future<Set<int>> getPersonIgnoredClusters(String personID) async {
+ Future<Set<String>> getPersonIgnoredClusters(String personID) async {
final db = await instance.asyncDB;
// find out clusterIds that are assigned to other persons using the clusters table
final List<Map<String, dynamic>> otherPersonMaps = await db.getAll(
'SELECT $clusterIDColumn FROM $clusterPersonTable WHERE $personIdColumn != ? AND $personIdColumn IS NOT NULL',
[personID],
);
- final Set<int> ignoredClusterIDs =
- otherPersonMaps.map((e) => e[clusterIDColumn] as int).toSet();
+ final Set<String> ignoredClusterIDs =
+ otherPersonMaps.map((e) => e[clusterIDColumn] as String).toSet();
final List<Map<String, dynamic>> rejectMaps = await db.getAll(
'SELECT $clusterIDColumn FROM $notPersonFeedback WHERE $personIdColumn = ?',
[personID],
);
- final Set<int> rejectClusterIDs =
- rejectMaps.map((e) => e[clusterIDColumn] as int).toSet();
+ final Set<String> rejectClusterIDs =
+ rejectMaps.map((e) => e[clusterIDColumn] as String).toSet();
return ignoredClusterIDs.union(rejectClusterIDs);
}
- Future<Set<int>> getPersonClusterIDs(String personID) async {
+ Future<Set<String>> getPersonClusterIDs(String personID) async {
final db = await instance.asyncDB;
final List<Map<String, dynamic>> maps = await db.getAll(
'SELECT $clusterIDColumn FROM $clusterPersonTable WHERE $personIdColumn = ?',
[personID],
);
- return maps.map((e) => e[clusterIDColumn] as int).toSet();
+ return maps.map((e) => e[clusterIDColumn] as String).toSet();
}
Future<void> clearTable() async {
@@ -235,7 +235,7 @@ class FaceMLDataDB {
}
Future<Iterable<Uint8List>> getFaceEmbeddingsForCluster(
- int clusterID, {
+ String clusterID, {
int? limit,
}) async {
final db = await instance.asyncDB;
@@ -246,12 +246,12 @@ class FaceMLDataDB {
return maps.map((e) => e[faceEmbeddingBlob] as Uint8List);
}
- Future<Map<int, Iterable<Uint8List>>> getFaceEmbeddingsForClusters(
- Iterable<int> clusterIDs, {
+ Future<Map<String, Iterable<Uint8List>>> getFaceEmbeddingsForClusters(
+ Iterable<String> clusterIDs, {
int? limit,
}) async {
final db = await instance.asyncDB;
- final Map<int, List<Uint8List>> result = {};
+ final Map<String, List<Uint8List>> result = {};
final selectQuery = '''
SELECT fc.$fcClusterID, fe.$faceEmbeddingBlob
@@ -264,7 +264,7 @@ class FaceMLDataDB {
final List<Map<String, dynamic>> maps = await db.getAll(selectQuery);
for (final map in maps) {
- final clusterID = map[fcClusterID] as int;
+ final clusterID = map[fcClusterID] as String;
final faceEmbedding = map[faceEmbeddingBlob] as Uint8List;
result.putIfAbsent(clusterID, () => <Uint8List>[]).add(faceEmbedding);
}
@@ -276,7 +276,7 @@ class FaceMLDataDB {
required int recentFileID,
String? personID,
String? avatarFaceId,
- int? clusterID,
+ String? clusterID,
}) async {
// read person from db
final db = await instance.asyncDB;
@@ -299,7 +299,7 @@ class FaceMLDataDB {
[personID],
);
final clusterIDs =
- clusterRows.map((e) => e[clusterIDColumn] as int).toList();
+ clusterRows.map((e) => e[clusterIDColumn] as String).toList();
final List<Map<String, dynamic>> faceMaps = await db.getAll(
'SELECT * FROM $facesTable where '
'$faceIDColumn in (SELECT $fcFaceId from $faceClustersTable where $fcClusterID IN (${clusterIDs.join(",")}))'
@@ -359,23 +359,23 @@ class FaceMLDataDB {
return maps.map((e) => mapRowToFace(e)).toList();
}
- Future<Map<int, Iterable<String>>> getClusterToFaceIDs(
- Set<int> clusterIDs,
+ Future<Map<String, Iterable<String>>> getClusterToFaceIDs(
+ Set<String> clusterIDs,
) async {
final db = await instance.asyncDB;
- final Map<int, List<String>> result = {};
+ final Map<String, List<String>> result = {};
final List<Map<String, dynamic>> maps = await db.getAll(
'SELECT $fcClusterID, $fcFaceId FROM $faceClustersTable WHERE $fcClusterID IN (${clusterIDs.join(",")})',
);
for (final map in maps) {
- final clusterID = map[fcClusterID] as int;
+ final clusterID = map[fcClusterID] as String;
final faceID = map[fcFaceId] as String;
result.putIfAbsent(clusterID, () => <String>[]).add(faceID);
}
return result;
}
- Future<int?> getClusterIDForFaceID(String faceID) async {
+ Future<String?> getClusterIDForFaceID(String faceID) async {
final db = await instance.asyncDB;
final List<Map<String, dynamic>> maps = await db.getAll(
'SELECT $fcClusterID FROM $faceClustersTable WHERE $fcFaceId = ?',
@@ -384,24 +384,24 @@ class FaceMLDataDB {
if (maps.isEmpty) {
return null;
}
- return maps.first[fcClusterID] as int;
+ return maps.first[fcClusterID] as String;
}
- Future<Map<int, Iterable<String>>> getAllClusterIdToFaceIDs() async {
+ Future<Map<String, Iterable<String>>> getAllClusterIdToFaceIDs() async {
final db = await instance.asyncDB;
- final Map<int, List<String>> result = {};
+ final Map<String, List<String>> result = {};
final List<Map<String, dynamic>> maps = await db.getAll(
'SELECT $fcClusterID, $fcFaceId FROM $faceClustersTable',
);
for (final map in maps) {
- final clusterID = map[fcClusterID] as int;
+ final clusterID = map[fcClusterID] as String;
final faceID = map[fcFaceId] as String;
result.putIfAbsent(clusterID, () => <String>[]).add(faceID);
}
return result;
}
- Future<Iterable<String>> getFaceIDsForCluster(int clusterID) async {
+ Future<Iterable<String>> getFaceIDsForCluster(String clusterID) async {
final db = await instance.asyncDB;
final List<Map<String, dynamic>> maps = await db.getAll(
'SELECT $fcFaceId FROM $faceClustersTable '
@@ -412,17 +412,17 @@ class FaceMLDataDB {
}
// Get Map of personID to Map of clusterID to faceIDs
- Future<Map<String, Map<int, Set<String>>>>
+ Future<Map<String, Map<String, Set<String>>>>
getPersonToClusterIdToFaceIds() async {
final db = await instance.asyncDB;
final List<Map<String, dynamic>> maps = await db.getAll(
'SELECT $personIdColumn, $faceClustersTable.$fcClusterID, $fcFaceId FROM $clusterPersonTable '
'LEFT JOIN $faceClustersTable ON $clusterPersonTable.$clusterIDColumn = $faceClustersTable.$fcClusterID',
);
- final Map<String, Map<int, Set<String>>> result = {};
+ final Map<String, Map<String, Set<String>>> result = {};
for (final map in maps) {
final personID = map[personIdColumn] as String;
- final clusterID = map[fcClusterID] as int;
+ final clusterID = map[fcClusterID] as String;
final faceID = map[fcFaceId] as String;
result
.putIfAbsent(personID, () => {})
@@ -443,7 +443,7 @@ class FaceMLDataDB {
return faceIdsResult.map((e) => e[fcFaceId] as String).toSet();
}
- Future<Iterable<double>> getBlurValuesForCluster(int clusterID) async {
+ Future<Iterable<double>> getBlurValuesForCluster(String clusterID) async {
final db = await instance.asyncDB;
const String query = '''
SELECT $facesTable.$faceBlur
@@ -463,29 +463,29 @@ class FaceMLDataDB {
return maps.map((e) => e[faceBlur] as double).toSet();
}
- Future<Map<String, int?>> getFaceIdsToClusterIds(
+ Future<Map<String, String?>> getFaceIdsToClusterIds(
Iterable<String> faceIds,
) async {
final db = await instance.asyncDB;
final List<Map<String, dynamic>> maps = await db.getAll(
'SELECT $fcFaceId, $fcClusterID FROM $faceClustersTable where $fcFaceId IN (${faceIds.map((id) => "'$id'").join(",")})',
);
- final Map<String, int?> result = {};
+ final Map<String, String?> result = {};
for (final map in maps) {
- result[map[fcFaceId] as String] = map[fcClusterID] as int?;
+ result[map[fcFaceId] as String] = map[fcClusterID] as String?;
}
return result;
}
- Future<Map<int, Set<int>>> getFileIdToClusterIds() async {
- final Map<int, Set<int>> result = {};
+ Future<Map<int, Set<String>>> getFileIdToClusterIds() async {
+ final Map<int, Set<String>> result = {};
final db = await instance.asyncDB;
final List<Map<String, dynamic>> maps = await db.getAll(
'SELECT $fcClusterID, $fcFaceId FROM $faceClustersTable',
);
for (final map in maps) {
- final clusterID = map[fcClusterID] as int;
+ final clusterID = map[fcClusterID] as String;
final faceID = map[fcFaceId] as String;
final fileID = getFileIdFromFaceId(faceID);
result[fileID] = (result[fileID] ?? {})..add(clusterID);
@@ -494,7 +494,7 @@ class FaceMLDataDB {
}
Future<void> forceUpdateClusterIds(
- Map<String, int> faceIDToClusterID,
+ Map<String, String> faceIDToClusterID,
) async {
final db = await instance.asyncDB;
@@ -681,7 +681,7 @@ class FaceMLDataDB {
Future<void> assignClusterToPerson({
required String personID,
- required int clusterID,
+ required String clusterID,
}) async {
final db = await instance.asyncDB;
@@ -692,7 +692,7 @@ class FaceMLDataDB {
}
Future<void> bulkAssignClusterToPersonID(
- Map<int, String> clusterToPersonID,
+ Map<String, String> clusterToPersonID,
) async {
final db = await instance.asyncDB;
@@ -706,7 +706,7 @@ class FaceMLDataDB {
Future<void> captureNotPersonFeedback({
required String personID,
- required int clusterID,
+ required String clusterID,
}) async {
final db = await instance.asyncDB;
@@ -717,7 +717,7 @@ class FaceMLDataDB {
}
Future<void> bulkCaptureNotPersonFeedback(
- Map<int, String> clusterToPersonID,
+ Map<String, String> clusterToPersonID,
) async {
final db = await instance.asyncDB;
@@ -732,7 +732,7 @@ class FaceMLDataDB {
Future<void> removeNotPersonFeedback({
required String personID,
- required int clusterID,
+ required String clusterID,
}) async {
final db = await instance.asyncDB;
@@ -744,7 +744,7 @@ class FaceMLDataDB {
Future<void> removeClusterToPerson({
required String personID,
- required int clusterID,
+ required String clusterID,
}) async {
final db = await instance.asyncDB;
@@ -755,7 +755,7 @@ class FaceMLDataDB {
}
// for a given personID, return a map of clusterID to fileIDs using join query
- Future<Map<int, Set<int>>> getFileIdToClusterIDSet(String personID) {
+ Future<Map<int, Set<String>>> getFileIdToClusterIDSet(String personID) {
final db = instance.asyncDB;
return db.then((db) async {
final List<Map<String, dynamic>> maps = await db.getAll(
@@ -765,9 +765,9 @@ class FaceMLDataDB {
'WHERE $clusterPersonTable.$personIdColumn = ?',
[personID],
);
- final Map<int, Set<int>> result = {};
+ final Map<int, Set<String>> result = {};
for (final map in maps) {
- final clusterID = map[clusterIDColumn] as int;
+ final clusterID = map[clusterIDColumn] as String;
final String faceID = map[fcFaceId] as String;
final fileID = getFileIdFromFaceId(faceID);
result[fileID] = (result[fileID] ?? {})..add(clusterID);
@@ -776,8 +776,8 @@ class FaceMLDataDB {
});
}
- Future<Map<int, Set<int>>> getFileIdToClusterIDSetForCluster(
- Set<int> clusterIDs,
+ Future<Map<int, Set<String>>> getFileIdToClusterIDSetForCluster(
+ Set<String> clusterIDs,
) {
final db = instance.asyncDB;
return db.then((db) async {
@@ -785,9 +785,9 @@ class FaceMLDataDB {
'SELECT $fcClusterID, $fcFaceId FROM $faceClustersTable '
'WHERE $fcClusterID IN (${clusterIDs.join(",")})',
);
- final Map<int, Set<int>> result = {};
+ final Map<int, Set<String>> result = {};
for (final map in maps) {
- final clusterID = map[fcClusterID] as int;
+ final clusterID = map[fcClusterID] as String;
final faceID = map[fcFaceId] as String;
final fileID = getFileIdFromFaceId(faceID);
result[fileID] = (result[fileID] ?? {})..add(clusterID);
@@ -796,7 +796,9 @@ class FaceMLDataDB {
});
}
- Future<void> clusterSummaryUpdate(Map<int, (Uint8List, int)> summary) async {
+ Future<void> clusterSummaryUpdate(
+ Map<String, (Uint8List, int)> summary,
+ ) async {
final db = await instance.asyncDB;
const String sql = '''
@@ -810,7 +812,7 @@ class FaceMLDataDB {
batchCounter = 0;
parameterSets.clear();
}
- final int clusterID = entry.key;
+ final String clusterID = entry.key;
final int count = entry.value.$2;
final Uint8List avg = entry.value.$1;
parameterSets.add([clusterID, avg, count]);
@@ -819,7 +821,7 @@ class FaceMLDataDB {
await db.executeBatch(sql, parameterSets);
}
- Future<void> deleteClusterSummary(int clusterID) async {
+ Future<void> deleteClusterSummary(String clusterID) async {
final db = await instance.asyncDB;
const String sqlDelete =
'DELETE FROM $clusterSummaryTable WHERE $clusterIDColumn = ?';
@@ -827,16 +829,16 @@ class FaceMLDataDB {
}
/// Returns a map of clusterID to (avg embedding, count)
- Future<Map<int, (Uint8List, int)>> getAllClusterSummary([
+ Future<Map<String, (Uint8List, int)>> getAllClusterSummary([
int? minClusterSize,
]) async {
final db = await instance.asyncDB;
- final Map<int, (Uint8List, int)> result = {};
+ final Map<String, (Uint8List, int)> result = {};
final rows = await db.getAll(
'SELECT * FROM $clusterSummaryTable${minClusterSize != null ? ' WHERE $countColumn >= $minClusterSize' : ''}',
);
for (final r in rows) {
- final id = r[clusterIDColumn] as int;
+ final id = r[clusterIDColumn] as String;
final avg = r[avgColumn] as Uint8List;
final count = r[countColumn] as int;
result[id] = (avg, count);
@@ -844,16 +846,16 @@ class FaceMLDataDB {
return result;
}
- Future<Map<int, (Uint8List, int)>> getClusterToClusterSummary(
- Iterable<int> clusterIDs,
+ Future<Map<String, (Uint8List, int)>> getClusterToClusterSummary(
+ Iterable<String> clusterIDs,
) async {
final db = await instance.asyncDB;
- final Map<int, (Uint8List, int)> result = {};
+ final Map<String, (Uint8List, int)> result = {};
final rows = await db.getAll(
'SELECT * FROM $clusterSummaryTable WHERE $clusterIDColumn IN (${clusterIDs.join(",")})',
);
for (final r in rows) {
- final id = r[clusterIDColumn] as int;
+ final id = r[clusterIDColumn] as String;
final avg = r[avgColumn] as Uint8List;
final count = r[countColumn] as int;
result[id] = (avg, count);
@@ -861,14 +863,14 @@ class FaceMLDataDB {
return result;
}
- Future<Map<int, String>> getClusterIDToPersonID() async {
+ Future<Map<String, String>> getClusterIDToPersonID() async {
final db = await instance.asyncDB;
final List<Map<String, dynamic>> maps = await db.getAll(
'SELECT $personIdColumn, $clusterIDColumn FROM $clusterPersonTable',
);
- final Map<int, String> result = {};
+ final Map<String, String> result = {};
for (final map in maps) {
- result[map[clusterIDColumn] as int] = map[personIdColumn] as String;
+ result[map[clusterIDColumn] as String] = map[personIdColumn] as String;
}
return result;
}
diff --git a/mobile/lib/face/db_fields.dart b/mobile/lib/face/db_fields.dart
index 8ad14ae282..c1de4780bc 100644
--- a/mobile/lib/face/db_fields.dart
+++ b/mobile/lib/face/db_fields.dart
@@ -41,7 +41,7 @@ const fcFaceId = 'face_id';
const createFaceClustersTable = '''
CREATE TABLE IF NOT EXISTS $faceClustersTable (
$fcFaceId TEXT NOT NULL,
- $fcClusterID INTEGER NOT NULL,
+ $fcClusterID TEXT NOT NULL,
PRIMARY KEY($fcFaceId)
);
''';
@@ -59,7 +59,7 @@ const clusterIDColumn = 'cluster_id';
const createClusterPersonTable = '''
CREATE TABLE IF NOT EXISTS $clusterPersonTable (
$personIdColumn TEXT NOT NULL,
- $clusterIDColumn INTEGER NOT NULL,
+ $clusterIDColumn TEXT NOT NULL,
PRIMARY KEY($personIdColumn, $clusterIDColumn)
);
''';
@@ -72,7 +72,7 @@ const avgColumn = 'avg';
const countColumn = 'count';
const createClusterSummaryTable = '''
CREATE TABLE IF NOT EXISTS $clusterSummaryTable (
- $clusterIDColumn INTEGER NOT NULL,
+ $clusterIDColumn TEXT NOT NULL,
$avgColumn BLOB NOT NULL,
$countColumn INTEGER NOT NULL,
PRIMARY KEY($clusterIDColumn)
@@ -89,7 +89,7 @@ const notPersonFeedback = 'not_person_feedback';
const createNotPersonFeedbackTable = '''
CREATE TABLE IF NOT EXISTS $notPersonFeedback (
$personIdColumn TEXT NOT NULL,
- $clusterIDColumn INTEGER NOT NULL,
+ $clusterIDColumn TEXT NOT NULL,
PRIMARY KEY($personIdColumn, $clusterIDColumn)
);
''';
diff --git a/mobile/lib/face/model/person.dart b/mobile/lib/face/model/person.dart
index cedec7a0dc..7536d3b0a6 100644
--- a/mobile/lib/face/model/person.dart
+++ b/mobile/lib/face/model/person.dart
@@ -24,7 +24,7 @@ class PersonEntity {
}
class ClusterInfo {
- final int id;
+ final String id;
final Set<String> faces;
ClusterInfo({
required this.id,
@@ -40,7 +40,7 @@ class ClusterInfo {
// from Json
factory ClusterInfo.fromJson(Map<String, dynamic> json) {
return ClusterInfo(
- id: json['id'] as int,
+ id: json['id'] as String,
faces: (json['faces'] as List<dynamic>).map((e) => e as String).toSet(),
);
}
diff --git a/mobile/lib/models/nanoids/cluster_id.dart b/mobile/lib/models/nanoids/cluster_id.dart
index 2376c7a014..278e0bb1a2 100644
--- a/mobile/lib/models/nanoids/cluster_id.dart
+++ b/mobile/lib/models/nanoids/cluster_id.dart
@@ -6,26 +6,12 @@ const alphaphet =
const clusterIDLength = 22;
class ClusterID {
- final String value;
-
- // Private constructor
- ClusterID._internal(this.value);
-
- // Factory constructor with validation
- factory ClusterID(String value) {
- if (!_isValidClusterID(value)) {
- throw const FormatException('Invalid NanoID format');
- }
- return ClusterID._internal(value);
- }
-
- // Static method to generate a new NanoID
- static ClusterID generate() {
- return ClusterID("cluster_${customAlphabet(urlAlphabet, clusterIDLength)}");
+ static String generate() {
+ return "cluster_${customAlphabet(urlAlphabet, clusterIDLength)}";
}
// Validation method
- static bool _isValidClusterID(String value) {
+ static bool isValidClusterID(String value) {
if (value.length != (clusterIDLength + 8)) {
debugPrint("ClusterID length is not ${clusterIDLength + 8}: $value");
return false;
@@ -36,24 +22,4 @@ class ClusterID {
}
return true;
}
-
- // Override == operator
- @override
- bool operator ==(Object other) {
- if (identical(this, other)) return true;
- return other is ClusterID && other.value == value;
- }
-
- // Override hashCode
- @override
- int get hashCode => value.hashCode;
-
- @override
- String toString() => value;
-
- String toJson() => value;
-
- static ClusterID fromJson(String value) {
- return ClusterID(value);
- }
}
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 69b8fc06b8..d33b69c97a 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
@@ -1,7 +1,6 @@
import "dart:async";
import "dart:developer";
import "dart:isolate";
-import "dart:math" show max;
import "dart:typed_data" show Uint8List;
import "package:computer/computer.dart";
@@ -10,6 +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/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";
@@ -21,7 +21,7 @@ class FaceInfo {
final double? blurValue;
final bool? badFace;
final Vector? vEmbedding;
- int? clusterId;
+ String? clusterId;
String? closestFaceId;
int? closestDist;
int? fileCreationTime;
@@ -39,9 +39,9 @@ class FaceInfo {
enum ClusterOperation { linearIncrementalClustering }
class ClusteringResult {
- final Map<String, int> newFaceIdToCluster;
- final Map<int, List<String>> newClusterIdToFaceIds;
- final Map<int, (Uint8List, int)> newClusterSummaries;
+ final Map<String, String> newFaceIdToCluster;
+ final Map<String, List<String>> newClusterIdToFaceIds;
+ final Map<String, (Uint8List, int)> newClusterSummaries;
bool get isEmpty => newFaceIdToCluster.isEmpty;
@@ -210,7 +210,7 @@ class FaceClusteringService {
double conservativeDistanceThreshold = kConservativeDistanceThreshold,
bool useDynamicThreshold = true,
int? offset,
- required Map<int, (Uint8List, int)> oldClusterSummaries,
+ required Map<String, (Uint8List, int)> oldClusterSummaries,
}) async {
if (input.isEmpty) {
_logger.warning(
@@ -417,7 +417,7 @@ ClusteringResult _runLinearClustering(Map args) {
final useDynamicThreshold = args['useDynamicThreshold'] as bool;
final offset = args['offset'] as int?;
final oldClusterSummaries =
- args['oldClusterSummaries'] as Map<int, (Uint8List, int)>?;
+ args['oldClusterSummaries'] as Map<String, (Uint8List, int)>?;
log(
"[ClusterIsolate] ${DateTime.now()} Copied to isolate ${input.length} faces",
@@ -491,17 +491,17 @@ 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
- int clusterID = DateTime.now().microsecondsSinceEpoch;
+ String clusterID = ClusterID.generate();
if (facesWithClusterID.isEmpty) {
// assign a clusterID to the first face
sortedFaceInfos[0].clusterId = clusterID;
- clusterID++;
+ clusterID = ClusterID.generate();
}
final stopwatchClustering = Stopwatch()..start();
for (int i = 1; i < totalFaces; i++) {
// Incremental clustering, so we can skip faces that already have a clusterId
if (sortedFaceInfos[i].clusterId != null) {
- clusterID = max(clusterID, sortedFaceInfos[i].clusterId!);
+ // clusterID = max(clusterID, sortedFaceInfos[i].clusterId!);
continue;
}
@@ -539,25 +539,25 @@ ClusteringResult _runLinearClustering(Map args) {
log(
" [ClusterIsolate] [WARNING] ${DateTime.now()} Found new cluster $clusterID",
);
- clusterID++;
+ clusterID = ClusterID.generate();
sortedFaceInfos[closestIdx].clusterId = clusterID;
}
sortedFaceInfos[i].clusterId = sortedFaceInfos[closestIdx].clusterId;
} else {
- clusterID++;
+ clusterID = ClusterID.generate();
sortedFaceInfos[i].clusterId = clusterID;
}
}
// Finally, assign the new clusterId to the faces
- final Map<String, int> newFaceIdToCluster = {};
+ final Map<String, String> newFaceIdToCluster = {};
final newClusteredFaceInfos = sortedFaceInfos.sublist(alreadyClusteredCount);
for (final faceInfo in newClusteredFaceInfos) {
newFaceIdToCluster[faceInfo.faceID] = faceInfo.clusterId!;
}
// Create a map of clusterId to faceIds
- final Map<int, List<String>> clusterIdToFaceIds = {};
+ final Map<String, List<String>> clusterIdToFaceIds = {};
for (final entry in newFaceIdToCluster.entries) {
final clusterID = entry.value;
if (clusterIdToFaceIds.containsKey(clusterID)) {
@@ -599,7 +599,7 @@ ClusteringResult _runCompleteClustering(Map args) {
final distanceThreshold = args['distanceThreshold'] as double;
final mergeThreshold = args['mergeThreshold'] as double;
final oldClusterSummaries =
- args['oldClusterSummaries'] as Map<int, (Uint8List, int)>?;
+ args['oldClusterSummaries'] as Map<String, (Uint8List, int)>?;
log(
"[CompleteClustering] ${DateTime.now()} Copied to isolate ${input.length} faces for clustering",
@@ -634,11 +634,10 @@ ClusteringResult _runCompleteClustering(Map args) {
"[CompleteClustering] ${DateTime.now()} Processing $totalFaces faces in one single round of complete clustering",
);
- // set current epoch time as clusterID
- int clusterID = DateTime.now().microsecondsSinceEpoch;
+ String clusterID = ClusterID.generate();
// Start actual clustering
- final Map<String, int> newFaceIdToCluster = {};
+ final Map<String, String> newFaceIdToCluster = {};
final stopwatchClustering = Stopwatch()..start();
for (int i = 0; i < totalFaces; i++) {
if ((i + 1) % 250 == 0) {
@@ -659,18 +658,18 @@ ClusteringResult _runCompleteClustering(Map args) {
if (closestDistance < distanceThreshold) {
if (faceInfos[closestIdx].clusterId == null) {
- clusterID++;
+ clusterID = ClusterID.generate();
faceInfos[closestIdx].clusterId = clusterID;
}
faceInfos[i].clusterId = faceInfos[closestIdx].clusterId!;
} else {
- clusterID++;
+ clusterID = ClusterID.generate();
faceInfos[i].clusterId = clusterID;
}
}
// Now calculate the mean of the embeddings for each cluster
- final Map<int, List<FaceInfo>> clusterIdToFaceInfos = {};
+ final Map<String, List<FaceInfo>> clusterIdToFaceInfos = {};
for (final faceInfo in faceInfos) {
if (clusterIdToFaceInfos.containsKey(faceInfo.clusterId)) {
clusterIdToFaceInfos[faceInfo.clusterId]!.add(faceInfo);
@@ -678,7 +677,7 @@ ClusteringResult _runCompleteClustering(Map args) {
clusterIdToFaceInfos[faceInfo.clusterId!] = [faceInfo];
}
}
- final Map<int, (Vector, int)> clusterIdToMeanEmbeddingAndWeight = {};
+ final Map<String, (Vector, int)> clusterIdToMeanEmbeddingAndWeight = {};
for (final clusterId in clusterIdToFaceInfos.keys) {
final List<Vector> embeddings = clusterIdToFaceInfos[clusterId]!
.map((faceInfo) => faceInfo.vEmbedding!)
@@ -691,13 +690,14 @@ ClusteringResult _runCompleteClustering(Map args) {
}
// Now merge the clusters that are close to each other, based on mean embedding
- final List<(int, int)> mergedClustersList = [];
- final List<int> clusterIds = clusterIdToMeanEmbeddingAndWeight.keys.toList();
+ final List<(String, String)> mergedClustersList = [];
+ final List<String> clusterIds =
+ clusterIdToMeanEmbeddingAndWeight.keys.toList();
log(' [CompleteClustering] ${DateTime.now()} ${clusterIds.length} clusters found, now checking for merges');
while (true) {
if (clusterIds.length < 2) break;
double distance = double.infinity;
- (int, int) clusterIDsToMerge = (-1, -1);
+ (String, String) clusterIDsToMerge = ('', '');
for (int i = 0; i < clusterIds.length; i++) {
for (int j = 0; j < clusterIds.length; j++) {
if (i == j) continue;
@@ -749,7 +749,7 @@ ClusteringResult _runCompleteClustering(Map args) {
newFaceIdToCluster[faceInfo.faceID] = faceInfo.clusterId!;
}
- final Map<int, List<String>> clusterIdToFaceIds = {};
+ final Map<String, List<String>> clusterIdToFaceIds = {};
for (final entry in newFaceIdToCluster.entries) {
final clusterID = entry.value;
if (clusterIdToFaceIds.containsKey(clusterID)) {
@@ -794,12 +794,12 @@ void _sortFaceInfosOnCreationTime(
});
}
-Map<int, (Uint8List, int)> _updateClusterSummaries({
+Map<String, (Uint8List, int)> _updateClusterSummaries({
required List<FaceInfo> newFaceInfos,
- Map<int, (Uint8List, int)>? oldSummary,
+ Map<String, (Uint8List, int)>? oldSummary,
}) {
final calcSummariesStart = DateTime.now();
- final Map<int, List<FaceInfo>> newClusterIdToFaceInfos = {};
+ final Map<String, List<FaceInfo>> newClusterIdToFaceInfos = {};
for (final faceInfo in newFaceInfos) {
if (newClusterIdToFaceInfos.containsKey(faceInfo.clusterId!)) {
newClusterIdToFaceInfos[faceInfo.clusterId!]!.add(faceInfo);
@@ -808,7 +808,7 @@ Map<int, (Uint8List, int)> _updateClusterSummaries({
}
}
- final Map<int, (Uint8List, int)> newClusterSummaries = {};
+ final Map<String, (Uint8List, int)> newClusterSummaries = {};
for (final clusterId in newClusterIdToFaceInfos.keys) {
final List<Vector> newEmbeddings = newClusterIdToFaceInfos[clusterId]!
.map((faceInfo) => faceInfo.vEmbedding!)
@@ -849,13 +849,13 @@ void _analyzeClusterResults(List<FaceInfo> sortedFaceInfos) {
if (!kDebugMode) return;
final stopwatch = Stopwatch()..start();
- final Map<String, int> faceIdToCluster = {};
+ final Map<String, String> faceIdToCluster = {};
for (final faceInfo in sortedFaceInfos) {
faceIdToCluster[faceInfo.faceID] = faceInfo.clusterId!;
}
// Find faceIDs that are part of a cluster which is larger than 5 and are new faceIDs
- final Map<int, int> clusterIdToSize = {};
+ final Map<String, int> clusterIdToSize = {};
faceIdToCluster.forEach((key, value) {
if (clusterIdToSize.containsKey(value)) {
clusterIdToSize[value] = clusterIdToSize[value]! + 1;
diff --git a/mobile/lib/services/machine_learning/face_ml/face_clustering/face_db_info_for_clustering.dart b/mobile/lib/services/machine_learning/face_ml/face_clustering/face_db_info_for_clustering.dart
index 12754301bb..1822d3fb55 100644
--- a/mobile/lib/services/machine_learning/face_ml/face_clustering/face_db_info_for_clustering.dart
+++ b/mobile/lib/services/machine_learning/face_ml/face_clustering/face_db_info_for_clustering.dart
@@ -2,7 +2,7 @@ import "dart:typed_data" show Uint8List;
class FaceDbInfoForClustering {
final String faceID;
- int? clusterId;
+ String? clusterId;
final Uint8List embeddingBytes;
final double faceScore;
final double blurValue;
diff --git a/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart b/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart
index 9da4f1ce2f..85fb95af75 100644
--- a/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart
+++ b/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart
@@ -20,7 +20,7 @@ import "package:photos/services/machine_learning/ml_result.dart";
import "package:photos/services/search_service.dart";
class ClusterSuggestion {
- final int clusterIDToMerge;
+ final String clusterIDToMerge;
final double distancePersonToCluster;
final bool usedOnlyMeanForSuggestion;
final List<EnteFile> filesInCluster;
@@ -43,13 +43,13 @@ class ClusterFeedbackService {
static final ClusterFeedbackService instance =
ClusterFeedbackService._privateConstructor();
- static int lastViewedClusterID = -1;
- static setLastViewedClusterID(int clusterID) {
+ static String lastViewedClusterID = '';
+ static setLastViewedClusterID(String clusterID) {
lastViewedClusterID = clusterID;
}
static resetLastViewedClusterID() {
- lastViewedClusterID = -1;
+ lastViewedClusterID = '';
}
/// Returns a list of cluster suggestions for a person. Each suggestion is a tuple of the following elements:
@@ -68,7 +68,7 @@ class ClusterFeedbackService {
try {
// Get the suggestions for the person using centroids and median
final startTime = DateTime.now();
- final List<(int, double, bool)> foundSuggestions =
+ final List<(String, double, bool)> foundSuggestions =
await _getSuggestions(person);
final findSuggestionsTime = DateTime.now();
_logger.info(
@@ -77,13 +77,13 @@ class ClusterFeedbackService {
// Get the files for the suggestions
final suggestionClusterIDs = foundSuggestions.map((e) => e.$1).toSet();
- final Map<int, Set<int>> fileIdToClusterID =
+ final Map<int, Set<String>> fileIdToClusterID =
await FaceMLDataDB.instance.getFileIdToClusterIDSetForCluster(
suggestionClusterIDs,
);
final clusterIdToFaceIDs =
await FaceMLDataDB.instance.getClusterToFaceIDs(suggestionClusterIDs);
- final Map<int, List<EnteFile>> clusterIDToFiles = {};
+ final Map<String, List<EnteFile>> clusterIDToFiles = {};
final allFiles = await SearchService.instance.getAllFiles();
for (final f in allFiles) {
if (!fileIdToClusterID.containsKey(f.uploadedFileID ?? -1)) {
@@ -180,7 +180,7 @@ class ClusterFeedbackService {
.clusterSummaryUpdate(clusterResult.newClusterSummaries);
// Make sure the deleted faces don't get suggested in the future
- final notClusterIdToPersonId = <int, String>{};
+ final notClusterIdToPersonId = <String, String>{};
for (final clusterId in newFaceIdToClusterID.values.toSet()) {
notClusterIdToPersonId[clusterId] = p.remoteID;
}
@@ -202,7 +202,7 @@ class ClusterFeedbackService {
Future<void> removeFilesFromCluster(
List<EnteFile> files,
- int clusterID,
+ String clusterID,
) async {
_logger.info('removeFilesFromCluster called');
try {
@@ -260,8 +260,8 @@ class ClusterFeedbackService {
}
}
- Future<void> addFacesToCluster(List<String> faceIDs, int clusterID) async {
- final faceIDToClusterID = <String, int>{};
+ Future<void> addFacesToCluster(List<String> faceIDs, String clusterID) async {
+ final faceIDToClusterID = <String, String>{};
for (final faceID in faceIDs) {
faceIDToClusterID[faceID] = clusterID;
}
@@ -272,7 +272,7 @@ class ClusterFeedbackService {
Future<bool> checkAndDoAutomaticMerges(
PersonEntity p, {
- required int personClusterID,
+ required String personClusterID,
}) async {
final faceMlDb = FaceMLDataDB.instance;
final faceIDs = await faceMlDb.getFaceIDsForCluster(personClusterID);
@@ -293,7 +293,7 @@ class ClusterFeedbackService {
// Get and update the cluster summary to get the avg (centroid) and count
final EnteWatch watch = EnteWatch("ClusterFeedbackService")..start();
- final Map<int, Vector> clusterAvg = await _getUpdateClusterAvg(
+ final Map<String, Vector> clusterAvg = await _getUpdateClusterAvg(
allClusterIdsToCountMap,
ignoredClusters,
minClusterSize: kMinimumClusterSizeSearchResult,
@@ -301,7 +301,8 @@ class ClusterFeedbackService {
watch.log('computed avg for ${clusterAvg.length} clusters');
// Find the actual closest clusters for the person
- final List<(int, double)> suggestions = await calcSuggestionsMeanInComputer(
+ final List<(String, double)> suggestions =
+ await calcSuggestionsMeanInComputer(
clusterAvg,
{personClusterID},
ignoredClusters,
@@ -333,16 +334,16 @@ class ClusterFeedbackService {
return true;
}
- Future<void> ignoreCluster(int clusterID) async {
+ Future<void> ignoreCluster(String clusterID) async {
await PersonService.instance.addPerson('', clusterID);
Bus.instance.fire(PeopleChangedEvent());
return;
}
- Future<List<(int, int)>> checkForMixedClusters() async {
+ Future<List<(String, int)>> checkForMixedClusters() async {
final faceMlDb = FaceMLDataDB.instance;
final allClusterToFaceCount = await faceMlDb.clusterIdToFaceCount();
- final clustersToInspect = <int>[];
+ final clustersToInspect = <String>[];
for (final clusterID in allClusterToFaceCount.keys) {
if (allClusterToFaceCount[clusterID]! > 20 &&
allClusterToFaceCount[clusterID]! < 500) {
@@ -353,7 +354,7 @@ class ClusterFeedbackService {
final fileIDToCreationTime =
await FilesDB.instance.getFileIDToCreationTime();
- final susClusters = <(int, int)>[];
+ final susClusters = <(String, int)>[];
final inspectionStart = DateTime.now();
for (final clusterID in clustersToInspect) {
@@ -387,15 +388,15 @@ class ClusterFeedbackService {
);
// Now find the sizes of the biggest and second biggest cluster
- final int biggestClusterID = newClusterIdToCount.keys.reduce((a, b) {
+ final String biggestClusterID = newClusterIdToCount.keys.reduce((a, b) {
return newClusterIdToCount[a]! > newClusterIdToCount[b]! ? a : b;
});
final int biggestSize = newClusterIdToCount[biggestClusterID]!;
final biggestRatio = biggestSize / originalClusterSize;
if (newClusterIdToCount.length > 1) {
- final List<int> clusterIDs = newClusterIdToCount.keys.toList();
+ final List<String> clusterIDs = newClusterIdToCount.keys.toList();
clusterIDs.remove(biggestClusterID);
- final int secondBiggestClusterID = clusterIDs.reduce((a, b) {
+ final String secondBiggestClusterID = clusterIDs.reduce((a, b) {
return newClusterIdToCount[a]! > newClusterIdToCount[b]! ? a : b;
});
final int secondBiggestSize =
@@ -432,7 +433,7 @@ class ClusterFeedbackService {
}
Future<ClusteringResult> breakUpCluster(
- int clusterID, {
+ String clusterID, {
bool useDbscan = false,
}) async {
_logger.info(
@@ -491,7 +492,7 @@ class ClusterFeedbackService {
/// 1. clusterID: the ID of the cluster
/// 2. distance: the distance between the person's cluster and the suggestion
/// 3. usedMean: whether the suggestion was found using the mean (true) or the median (false)
- Future<List<(int, double, bool)>> _getSuggestions(
+ Future<List<(String, double, bool)>> _getSuggestions(
PersonEntity p, {
int sampleSize = 50,
double maxMedianDistance = 0.62,
@@ -520,8 +521,8 @@ class ClusterFeedbackService {
.map((clusterID) => allClusterIdsToCountMap[clusterID] ?? 0)
.reduce((value, element) => min(value, element));
final checkSizes = [100, 20, kMinimumClusterSizeSearchResult, 10, 5, 1];
- Map<int, Vector> clusterAvgBigClusters = <int, Vector>{};
- final List<(int, double)> suggestionsMean = [];
+ Map<String, Vector> clusterAvgBigClusters = <String, Vector>{};
+ final List<(String, double)> suggestionsMean = [];
for (final minimumSize in checkSizes.toSet()) {
if (smallestPersonClusterSize >=
min(minimumSize, kMinimumClusterSizeSearchResult)) {
@@ -533,7 +534,7 @@ class ClusterFeedbackService {
w?.log(
'Calculate avg for ${clusterAvgBigClusters.length} clusters of min size $minimumSize',
);
- final List<(int, double)> suggestionsMeanBigClusters =
+ final List<(String, double)> suggestionsMeanBigClusters =
await calcSuggestionsMeanInComputer(
clusterAvgBigClusters,
personClusters,
@@ -570,7 +571,7 @@ class ClusterFeedbackService {
// Find the other cluster candidates based on the median
final clusterAvg = clusterAvgBigClusters;
- final List<(int, double)> moreSuggestionsMean =
+ final List<(String, double)> moreSuggestionsMean =
await calcSuggestionsMeanInComputer(
clusterAvg,
personClusters,
@@ -616,8 +617,8 @@ class ClusterFeedbackService {
.toList(growable: false);
// Find the actual closest clusters for the person using median
- final List<(int, double)> suggestionsMedian = [];
- final List<(int, double)> greatSuggestionsMedian = [];
+ final List<(String, double)> suggestionsMedian = [];
+ final List<(String, double)> greatSuggestionsMedian = [];
double minMedianDistance = maxMedianDistance;
for (final otherClusterId in otherClusterIdsCandidates) {
final Iterable<Uint8List> otherEmbeddingsProto =
@@ -663,11 +664,12 @@ class ClusterFeedbackService {
_logger.info("Found suggestions using median: $suggestionsMedian");
}
- final List<(int, double, bool)> finalSuggestionsMedian = suggestionsMedian
- .map(((e) => (e.$1, e.$2, false)))
- .toList(growable: false)
- .reversed
- .toList(growable: false);
+ final List<(String, double, bool)> finalSuggestionsMedian =
+ suggestionsMedian
+ .map(((e) => (e.$1, e.$2, false)))
+ .toList(growable: false)
+ .reversed
+ .toList(growable: false);
if (greatSuggestionsMedian.isNotEmpty) {
_logger.info(
@@ -687,9 +689,9 @@ class ClusterFeedbackService {
return finalSuggestionsMedian;
}
- Future<Map<int, Vector>> _getUpdateClusterAvg(
- Map<int, int> allClusterIdsToCountMap,
- Set<int> ignoredClusters, {
+ Future<Map<String, Vector>> _getUpdateClusterAvg(
+ Map<String, int> allClusterIdsToCountMap,
+ Set<String> ignoredClusters, {
int minClusterSize = 1,
int maxClusterInCurrentRun = 500,
int maxEmbeddingToRead = 10000,
@@ -701,9 +703,9 @@ class ClusterFeedbackService {
'start getUpdateClusterAvg for ${allClusterIdsToCountMap.length} clusters, minClusterSize $minClusterSize, maxClusterInCurrentRun $maxClusterInCurrentRun',
);
- final Map<int, (Uint8List, int)> clusterToSummary =
+ final Map<String, (Uint8List, int)> clusterToSummary =
await faceMlDb.getAllClusterSummary(minClusterSize);
- final Map<int, (Uint8List, int)> updatesForClusterSummary = {};
+ final Map<String, (Uint8List, int)> updatesForClusterSummary = {};
w?.log(
'getUpdateClusterAvg database call for getAllClusterSummary',
@@ -717,7 +719,7 @@ class ClusterFeedbackService {
'ignoredClusters': ignoredClusters,
'clusterToSummary': clusterToSummary,
},
- ) as (Map<int, Vector>, Set<int>, int, int, int);
+ ) as (Map<String, Vector>, Set<String>, int, int, int);
final clusterAvg = serializationEmbeddings.$1;
final allClusterIds = serializationEmbeddings.$2;
final ignoredClustersCnt = serializationEmbeddings.$3;
@@ -753,7 +755,7 @@ class ClusterFeedbackService {
w?.reset();
int currentPendingRead = 0;
- final List<int> clusterIdsToRead = [];
+ final List<String> clusterIdsToRead = [];
for (final clusterID in sortedClusterIDs) {
if (maxClusterInCurrentRun-- <= 0) {
break;
@@ -772,9 +774,9 @@ class ClusterFeedbackService {
}
}
- final Map<int, Iterable<Uint8List>> clusterEmbeddings = await FaceMLDataDB
- .instance
- .getFaceEmbeddingsForClusters(clusterIdsToRead);
+ final Map<String, Iterable<Uint8List>> clusterEmbeddings =
+ await FaceMLDataDB.instance
+ .getFaceEmbeddingsForClusters(clusterIdsToRead);
w?.logAndReset(
'read $currentPendingRead embeddings for ${clusterEmbeddings.length} clusters',
@@ -817,10 +819,10 @@ class ClusterFeedbackService {
return clusterAvg;
}
- Future<List<(int, double)>> calcSuggestionsMeanInComputer(
- Map<int, Vector> clusterAvg,
- Set<int> personClusters,
- Set<int> ignoredClusters,
+ Future<List<(String, double)>> calcSuggestionsMeanInComputer(
+ Map<String, Vector> clusterAvg,
+ Set<String> personClusters,
+ Set<String> ignoredClusters,
double maxClusterDistance,
) async {
return await _computer.compute(
@@ -889,7 +891,7 @@ class ClusterFeedbackService {
// Get the cluster averages for the person's clusters and the suggestions' clusters
final personClusters = await faceMlDb.getPersonClusterIDs(person.remoteID);
- final Map<int, (Uint8List, int)> personClusterToSummary =
+ final Map<String, (Uint8List, int)> personClusterToSummary =
await faceMlDb.getClusterToClusterSummary(personClusters);
final clusterSummaryCallTime = DateTime.now();
@@ -975,7 +977,7 @@ class ClusterFeedbackService {
}
Future<void> debugLogClusterBlurValues(
- int clusterID, {
+ String clusterID, {
int? clusterSize,
bool logClusterSummary = false,
bool logBlurValues = false,
@@ -986,7 +988,8 @@ class ClusterFeedbackService {
_logger.info(
"Debug logging for cluster $clusterID${clusterSize != null ? ' with $clusterSize photos' : ''}",
);
- const int biggestClusterID = 1715061228725148;
+ // todo:(laurens) remove to review
+ const String biggestClusterID = 'some random id';
// Logging the cluster summary for the cluster
if (logClusterSummary) {
@@ -1117,21 +1120,22 @@ class ClusterFeedbackService {
}
/// Returns a map of person's clusterID to map of closest clusterID to with disstance
-List<(int, double)> _calcSuggestionsMean(Map<String, dynamic> args) {
+List<(String, double)> _calcSuggestionsMean(Map<String, dynamic> args) {
// Fill in args
- final Map<int, Vector> clusterAvg = args['clusterAvg'];
- final Set<int> personClusters = args['personClusters'];
- final Set<int> ignoredClusters = args['ignoredClusters'];
+ final Map<String, Vector> clusterAvg = args['clusterAvg'];
+ final Set<String> personClusters = args['personClusters'];
+ final Set<String> ignoredClusters = args['ignoredClusters'];
final double maxClusterDistance = args['maxClusterDistance'];
- final Map<int, List<(int, double)>> suggestions = {};
+ final Map<String, List<(String, double)>> suggestions = {};
const suggestionMax = 2000;
int suggestionCount = 0;
int comparisons = 0;
final w = (kDebugMode ? EnteWatch('getSuggestions') : null)?..start();
// ignore the clusters that belong to the person or is ignored
- Set<int> otherClusters = clusterAvg.keys.toSet().difference(personClusters);
+ Set<String> otherClusters =
+ clusterAvg.keys.toSet().difference(personClusters);
otherClusters = otherClusters.difference(ignoredClusters);
for (final otherClusterID in otherClusters) {
@@ -1140,7 +1144,7 @@ List<(int, double)> _calcSuggestionsMean(Map<String, dynamic> args) {
dev.log('[WARNING] no avg for othercluster $otherClusterID');
continue;
}
- int? nearestPersonCluster;
+ String? nearestPersonCluster;
double? minDistance;
for (final personCluster in personClusters) {
if (clusterAvg[personCluster] == null) {
@@ -1172,8 +1176,8 @@ List<(int, double)> _calcSuggestionsMean(Map<String, dynamic> args) {
);
if (suggestions.isNotEmpty) {
- final List<(int, double)> suggestClusterIds = [];
- for (final List<(int, double)> suggestion in suggestions.values) {
+ final List<(String, double)> suggestClusterIds = [];
+ for (final List<(String, double)> suggestion in suggestions.values) {
suggestClusterIds.addAll(suggestion);
}
suggestClusterIds.sort(
@@ -1186,20 +1190,22 @@ List<(int, double)> _calcSuggestionsMean(Map<String, dynamic> args) {
return suggestClusterIds.sublist(0, min(suggestClusterIds.length, 20));
} else {
dev.log("No suggestions found using mean");
- return <(int, double)>[];
+ return <(String, double)>[];
}
}
-Future<(Map<int, Vector>, Set<int>, int, int, int)>
+Future<(Map<String, Vector>, Set<String>, int, int, int)>
checkAndSerializeCurrentClusterMeans(
Map args,
) async {
- final Map<int, int> allClusterIdsToCountMap = args['allClusterIdsToCountMap'];
+ final Map<String, int> allClusterIdsToCountMap =
+ args['allClusterIdsToCountMap'];
final int minClusterSize = args['minClusterSize'] ?? 1;
- final Set<int> ignoredClusters = args['ignoredClusters'] ?? {};
- final Map<int, (Uint8List, int)> clusterToSummary = args['clusterToSummary'];
+ final Set<String> ignoredClusters = args['ignoredClusters'] ?? {};
+ final Map<String, (Uint8List, int)> clusterToSummary =
+ args['clusterToSummary'];
- final Map<int, Vector> clusterAvg = {};
+ final Map<String, Vector> clusterAvg = {};
final allClusterIds = allClusterIdsToCountMap.keys.toSet();
int ignoredClustersCnt = 0, alreadyUpdatedClustersCnt = 0;
diff --git a/mobile/lib/services/machine_learning/face_ml/person/person_service.dart b/mobile/lib/services/machine_learning/face_ml/person/person_service.dart
index 4931bb0eb7..187e51faf6 100644
--- a/mobile/lib/services/machine_learning/face_ml/person/person_service.dart
+++ b/mobile/lib/services/machine_learning/face_ml/person/person_service.dart
@@ -82,7 +82,7 @@ class PersonService {
continue;
}
final personData = person.data;
- final Map<int, Set<String>> dbPersonCluster =
+ final Map<String, Set<String>> dbPersonCluster =
dbPersonClusterInfo[personID]!;
if (_shouldUpdateRemotePerson(personData, dbPersonCluster)) {
final personData = person.data;
@@ -109,7 +109,7 @@ class PersonService {
bool _shouldUpdateRemotePerson(
PersonData personData,
- Map<int, Set<String>> dbPersonCluster,
+ Map<String, Set<String>> dbPersonCluster,
) {
bool result = false;
if ((personData.assigned?.length ?? 0) != dbPersonCluster.length) {
@@ -152,7 +152,7 @@ class PersonService {
Future<PersonEntity> addPerson(
String name,
- int clusterID, {
+ String clusterID, {
bool isHidden = false,
}) async {
final faceIds = await faceMLDataDB.getFaceIDsForCluster(clusterID);
@@ -179,7 +179,7 @@ class PersonService {
Future<void> removeClusterToPerson({
required String personID,
- required int clusterID,
+ required String clusterID,
}) async {
final person = (await getPerson(personID))!;
final personData = person.data;
@@ -201,7 +201,7 @@ class PersonService {
required Set<String> faceIDs,
}) async {
final personData = person.data;
- final List<int> emptiedClusters = [];
+ final List<String> emptiedClusters = [];
for (final cluster in personData.assigned!) {
cluster.faces.removeWhere((faceID) => faceIDs.contains(faceID));
if (cluster.faces.isEmpty) {
@@ -219,7 +219,6 @@ class PersonService {
);
}
-
await entityService.addOrUpdate(
EntityType.person,
json.encode(personData.toJson()),
@@ -256,8 +255,8 @@ class PersonService {
await entityService.syncEntities();
final entities = await entityService.getEntities(EntityType.person);
entities.sort((a, b) => a.updatedAt.compareTo(b.updatedAt));
- final Map<String, int> faceIdToClusterID = {};
- final Map<int, String> clusterToPersonID = {};
+ final Map<String, String> faceIdToClusterID = {};
+ final Map<String, String> clusterToPersonID = {};
for (var e in entities) {
final personData = PersonData.fromJson(json.decode(e.data));
int faceCount = 0;
diff --git a/mobile/lib/services/machine_learning/ml_service.dart b/mobile/lib/services/machine_learning/ml_service.dart
index 7bf0e2dfd5..1ed24f0d46 100644
--- a/mobile/lib/services/machine_learning/ml_service.dart
+++ b/mobile/lib/services/machine_learning/ml_service.dart
@@ -250,7 +250,7 @@ class MLService {
);
// Get the current cluster statistics
- final Map<int, (Uint8List, int)> oldClusterSummaries =
+ final Map<String, (Uint8List, int)> oldClusterSummaries =
await FaceMLDataDB.instance.getAllClusterSummary();
if (clusterInBuckets) {
diff --git a/mobile/lib/services/search_service.dart b/mobile/lib/services/search_service.dart
index b9b6736e3c..9329a79081 100644
--- a/mobile/lib/services/search_service.dart
+++ b/mobile/lib/services/search_service.dart
@@ -736,14 +736,14 @@ class SearchService {
return searchResults;
}
- Future<Map<int, List<EnteFile>>> getClusterFilesForPersonID(
+ Future<Map<String, List<EnteFile>>> getClusterFilesForPersonID(
String personID,
) async {
_logger.info('getClusterFilesForPersonID $personID');
- final Map<int, Set<int>> fileIdToClusterID =
+ final Map<int, Set<String>> fileIdToClusterID =
await FaceMLDataDB.instance.getFileIdToClusterIDSet(personID);
_logger.info('faceDbDone getClusterFilesForPersonID $personID');
- final Map<int, List<EnteFile>> clusterIDToFiles = {};
+ final Map<String, List<EnteFile>> clusterIDToFiles = {};
final allFiles = await getAllFiles();
for (final f in allFiles) {
if (!fileIdToClusterID.containsKey(f.uploadedFileID ?? -1)) {
@@ -765,7 +765,7 @@ class SearchService {
Future<List<GenericSearchResult>> getAllFace(int? limit) async {
try {
debugPrint("getting faces");
- final Map<int, Set<int>> fileIdToClusterID =
+ final Map<int, Set<String>> fileIdToClusterID =
await FaceMLDataDB.instance.getFileIdToClusterIds();
final Map<String, PersonEntity> personIdToPerson =
await PersonService.instance.getPersonsMap();
@@ -773,7 +773,7 @@ class SearchService {
await FaceMLDataDB.instance.getClusterIDToPersonID();
final List<GenericSearchResult> facesResult = [];
- final Map<int, List<EnteFile>> clusterIdToFiles = {};
+ final Map<String, List<EnteFile>> clusterIdToFiles = {};
final Map<String, List<EnteFile>> personIdToFiles = {};
final allFiles = await getAllFiles();
for (final f in allFiles) {
diff --git a/mobile/lib/ui/components/bottom_action_bar/bottom_action_bar_widget.dart b/mobile/lib/ui/components/bottom_action_bar/bottom_action_bar_widget.dart
index a0c50be21d..d295d85e1c 100644
--- a/mobile/lib/ui/components/bottom_action_bar/bottom_action_bar_widget.dart
+++ b/mobile/lib/ui/components/bottom_action_bar/bottom_action_bar_widget.dart
@@ -13,7 +13,7 @@ class BottomActionBarWidget extends StatelessWidget {
final GalleryType galleryType;
final Collection? collection;
final PersonEntity? person;
- final int? clusterID;
+ final String? clusterID;
final SelectedFiles selectedFiles;
final VoidCallback? onCancel;
final Color? backgroundColor;
diff --git a/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart b/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart
index 9e75474d40..cf90489c6d 100644
--- a/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart
+++ b/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart
@@ -53,7 +53,7 @@ class FileSelectionActionsWidget extends StatefulWidget {
final DeviceCollection? deviceCollection;
final SelectedFiles selectedFiles;
final PersonEntity? person;
- final int? clusterID;
+ final String? clusterID;
const FileSelectionActionsWidget(
this.type,
diff --git a/mobile/lib/ui/viewer/actions/file_selection_overlay_bar.dart b/mobile/lib/ui/viewer/actions/file_selection_overlay_bar.dart
index 9ba5adf3fb..bb9825f649 100644
--- a/mobile/lib/ui/viewer/actions/file_selection_overlay_bar.dart
+++ b/mobile/lib/ui/viewer/actions/file_selection_overlay_bar.dart
@@ -14,7 +14,7 @@ class FileSelectionOverlayBar extends StatefulWidget {
final Collection? collection;
final Color? backgroundColor;
final PersonEntity? person;
- final int? clusterID;
+ final String? clusterID;
const FileSelectionOverlayBar(
this.galleryType,
diff --git a/mobile/lib/ui/viewer/file_details/face_widget.dart b/mobile/lib/ui/viewer/file_details/face_widget.dart
index 9c0d7decdb..7465f7c8c0 100644
--- a/mobile/lib/ui/viewer/file_details/face_widget.dart
+++ b/mobile/lib/ui/viewer/file_details/face_widget.dart
@@ -9,6 +9,7 @@ import "package:photos/face/db.dart";
import "package:photos/face/model/face.dart";
import "package:photos/face/model/person.dart";
import 'package:photos/models/file/file.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";
@@ -24,7 +25,7 @@ class FaceWidget extends StatefulWidget {
final Face face;
final Future<Map<String, Uint8List>?>? faceCrops;
final PersonEntity? person;
- final int? clusterID;
+ final String? clusterID;
final bool highlight;
final bool editMode;
@@ -98,7 +99,7 @@ class _FaceWidgetState extends State<FaceWidget> {
}
// Create new clusterID for the faceID and update DB to assign the faceID to the new clusterID
- final int newClusterID = DateTime.now().microsecondsSinceEpoch;
+ final String newClusterID = ClusterID.generate();
await FaceMLDataDB.instance.updateFaceIdToClusterId(
{widget.face.faceID: newClusterID},
);
diff --git a/mobile/lib/ui/viewer/file_details/faces_item_widget.dart b/mobile/lib/ui/viewer/file_details/faces_item_widget.dart
index cb22e53b82..304beba5a4 100644
--- a/mobile/lib/ui/viewer/file_details/faces_item_widget.dart
+++ b/mobile/lib/ui/viewer/file_details/faces_item_widget.dart
@@ -146,7 +146,7 @@ class _FacesItemWidgetState extends State<FacesItemWidget> {
final faceCrops = getRelevantFaceCrops(faces);
for (final Face face in faces) {
- final int? clusterID = faceIdsToClusterIds[face.faceID];
+ final String? clusterID = faceIdsToClusterIds[face.faceID];
final PersonEntity? person = clusterIDToPerson[clusterID] != null
? persons[clusterIDToPerson[clusterID]!]
: null;
@@ -175,8 +175,7 @@ class _FacesItemWidgetState extends State<FacesItemWidget> {
Future<Map<String, Uint8List>?> getRelevantFaceCrops(
Iterable<Face> faces, {
int fetchAttempt = 1,
- }
- ) async {
+ }) async {
try {
final faceIdToCrop = <String, Uint8List>{};
final facesWithoutCrops = <String, FaceBox>{};
@@ -226,7 +225,7 @@ class _FacesItemWidgetState extends State<FacesItemWidget> {
stackTrace: s,
);
resetPool(fullFile: true);
- if(fetchAttempt <= retryLimit) {
+ if (fetchAttempt <= retryLimit) {
return getRelevantFaceCrops(faces, fetchAttempt: fetchAttempt + 1);
}
return null;
diff --git a/mobile/lib/ui/viewer/people/add_person_action_sheet.dart b/mobile/lib/ui/viewer/people/add_person_action_sheet.dart
index eb5b3e4b32..c868e60e71 100644
--- a/mobile/lib/ui/viewer/people/add_person_action_sheet.dart
+++ b/mobile/lib/ui/viewer/people/add_person_action_sheet.dart
@@ -47,7 +47,7 @@ String _actionName(
Future<dynamic> showAssignPersonAction(
BuildContext context, {
- required int clusterID,
+ required String clusterID,
PersonActionType actionType = PersonActionType.assignPerson,
bool showOptionToAddNewPerson = true,
}) {
@@ -75,7 +75,7 @@ Future<dynamic> showAssignPersonAction(
class PersonActionSheet extends StatefulWidget {
final PersonActionType actionType;
- final int cluserID;
+ final String cluserID;
final bool showOptionToCreateNewPerson;
const PersonActionSheet({
required this.actionType,
@@ -276,7 +276,7 @@ class _PersonActionSheetState extends State<PersonActionSheet> {
Future<void> addNewPerson(
BuildContext context, {
String initValue = '',
- required int clusterID,
+ required String clusterID,
}) async {
final result = await showTextInputDialog(
context,
diff --git a/mobile/lib/ui/viewer/people/cluster_app_bar.dart b/mobile/lib/ui/viewer/people/cluster_app_bar.dart
index fbfade9013..25b16aab34 100644
--- a/mobile/lib/ui/viewer/people/cluster_app_bar.dart
+++ b/mobile/lib/ui/viewer/people/cluster_app_bar.dart
@@ -26,7 +26,7 @@ class ClusterAppBar extends StatefulWidget {
final GalleryType type;
final String? title;
final SelectedFiles selectedFiles;
- final int clusterID;
+ final String clusterID;
final PersonEntity? person;
const ClusterAppBar(
@@ -179,7 +179,7 @@ class _AppBarWidgetState extends State<ClusterAppBar> {
Future<void> _breakUpCluster(BuildContext context) async {
bool userConfirmed = false;
List<EnteFile> biggestClusterFiles = [];
- int biggestClusterID = -1;
+ String biggestClusterID = '';
await showChoiceDialog(
context,
title: "Does this grouping contain multiple people?",
@@ -190,9 +190,9 @@ class _AppBarWidgetState extends State<ClusterAppBar> {
try {
final breakupResult = await ClusterFeedbackService.instance
.breakUpCluster(widget.clusterID);
- final Map<int, List<String>> newClusterIDToFaceIDs =
+ final Map<String, List<String>> newClusterIDToFaceIDs =
breakupResult.newClusterIdToFaceIds;
- final Map<String, int> newFaceIdToClusterID =
+ final Map<String, String> newFaceIdToClusterID =
breakupResult.newFaceIdToCluster;
// Update to delete the old clusters and save the new clusters
@@ -203,9 +203,9 @@ class _AppBarWidgetState extends State<ClusterAppBar> {
.updateFaceIdToClusterId(newFaceIdToClusterID);
// Find the biggest cluster
- biggestClusterID = -1;
+ biggestClusterID = '';
int biggestClusterSize = 0;
- for (final MapEntry<int, List<String>> clusterToFaces
+ for (final MapEntry<String, List<String>> clusterToFaces
in newClusterIDToFaceIDs.entries) {
if (clusterToFaces.value.length > biggestClusterSize) {
biggestClusterSize = clusterToFaces.value.length;
@@ -253,7 +253,7 @@ class _AppBarWidgetState extends State<ClusterAppBar> {
final breakupResult =
await ClusterFeedbackService.instance.breakUpCluster(widget.clusterID);
- final Map<int, List<String>> newClusterIDToFaceIDs =
+ final Map<String, List<String>> newClusterIDToFaceIDs =
breakupResult.newClusterIdToFaceIds;
final allFileIDs = newClusterIDToFaceIDs.values
diff --git a/mobile/lib/ui/viewer/people/cluster_breakup_page.dart b/mobile/lib/ui/viewer/people/cluster_breakup_page.dart
index 5644258325..c1bec40466 100644
--- a/mobile/lib/ui/viewer/people/cluster_breakup_page.dart
+++ b/mobile/lib/ui/viewer/people/cluster_breakup_page.dart
@@ -6,7 +6,7 @@ import "package:photos/ui/viewer/people/cluster_page.dart";
import "package:photos/ui/viewer/search/result/person_face_widget.dart";
class ClusterBreakupPage extends StatefulWidget {
- final Map<int, List<EnteFile>> newClusterIDsToFiles;
+ final Map<String, List<EnteFile>> newClusterIDsToFiles;
final String title;
const ClusterBreakupPage(
@@ -32,7 +32,7 @@ class _ClusterBreakupPageState extends State<ClusterBreakupPage> {
body: ListView.builder(
itemCount: widget.newClusterIDsToFiles.keys.length,
itemBuilder: (context, index) {
- final int clusterID = keys[index];
+ final String clusterID = keys[index];
final List<EnteFile> files = clusterIDsToFiles[keys[index]]!;
return InkWell(
onTap: () {
@@ -40,7 +40,7 @@ class _ClusterBreakupPageState extends State<ClusterBreakupPage> {
MaterialPageRoute(
builder: (context) => ClusterPage(
files,
- clusterID: index,
+ clusterID: clusterID,
appendTitle: "(Analysis)",
),
),
diff --git a/mobile/lib/ui/viewer/people/cluster_page.dart b/mobile/lib/ui/viewer/people/cluster_page.dart
index efca41ecab..05b89d8247 100644
--- a/mobile/lib/ui/viewer/people/cluster_page.dart
+++ b/mobile/lib/ui/viewer/people/cluster_page.dart
@@ -29,7 +29,7 @@ class ClusterPage extends StatefulWidget {
final List<EnteFile> searchResult;
final bool enableGrouping;
final String tagPrefix;
- final int clusterID;
+ final String clusterID;
final PersonEntity? personID;
final String appendTitle;
final bool showNamingBanner;
diff --git a/mobile/lib/ui/viewer/people/person_cluster_suggestion.dart b/mobile/lib/ui/viewer/people/person_cluster_suggestion.dart
index c3e788ffff..db1141fa9e 100644
--- a/mobile/lib/ui/viewer/people/person_cluster_suggestion.dart
+++ b/mobile/lib/ui/viewer/people/person_cluster_suggestion.dart
@@ -109,7 +109,7 @@ class _PersonClustersState extends State<PersonReviewClusterSuggestion> {
allSuggestions = snapshot.data!;
final numberOfDifferentSuggestions = allSuggestions.length;
final currentSuggestion = allSuggestions[currentSuggestionIndex];
- final int clusterID = currentSuggestion.clusterIDToMerge;
+ final String clusterID = currentSuggestion.clusterIDToMerge;
final double distance = currentSuggestion.distancePersonToCluster;
final bool usingMean = currentSuggestion.usedOnlyMeanForSuggestion;
final List<EnteFile> files = currentSuggestion.filesInCluster;
@@ -182,7 +182,7 @@ class _PersonClustersState extends State<PersonReviewClusterSuggestion> {
}
Future<void> _handleUserClusterChoice(
- int clusterID,
+ String clusterID,
bool yesOrNo,
int numberOfSuggestions,
) async {
@@ -229,7 +229,7 @@ class _PersonClustersState extends State<PersonReviewClusterSuggestion> {
}
Future<void> _rejectSuggestion(
- int clusterID,
+ String clusterID,
int numberOfSuggestions,
) async {
canGiveFeedback = false;
@@ -254,7 +254,7 @@ class _PersonClustersState extends State<PersonReviewClusterSuggestion> {
}
Widget _buildSuggestionView(
- int clusterID,
+ String clusterID,
double distance,
bool usingMean,
List<EnteFile> files,
@@ -379,7 +379,7 @@ class _PersonClustersState extends State<PersonReviewClusterSuggestion> {
Widget _buildThumbnailWidget(
List<EnteFile> files,
- int clusterID,
+ String clusterID,
Future<Map<int, Uint8List?>> generateFaceThumbnails,
) {
return SizedBox(
@@ -433,7 +433,7 @@ class _PersonClustersState extends State<PersonReviewClusterSuggestion> {
List<Widget> _buildThumbnailWidgetsRow(
List<EnteFile> files,
- int cluserId,
+ String cluserId,
Map<int, Uint8List?> faceThumbnails, {
int start = 0,
}) {
@@ -460,7 +460,7 @@ class _PersonClustersState extends State<PersonReviewClusterSuggestion> {
Future<Map<int, Uint8List?>> _generateFaceThumbnails(
List<EnteFile> files,
- int clusterID,
+ String clusterID,
) async {
final futures = <Future<Uint8List?>>[];
for (final file in files) {
diff --git a/mobile/lib/ui/viewer/people/person_clusters_page.dart b/mobile/lib/ui/viewer/people/person_clusters_page.dart
index 16d1131682..810fcbc779 100644
--- a/mobile/lib/ui/viewer/people/person_clusters_page.dart
+++ b/mobile/lib/ui/viewer/people/person_clusters_page.dart
@@ -32,12 +32,13 @@ class _PersonClustersPageState extends State<PersonClustersPage> {
appBar: AppBar(
title: Text(widget.person.data.name),
),
- body: FutureBuilder<Map<int, List<EnteFile>>>(
- future: SearchService.instance.getClusterFilesForPersonID(widget.person.remoteID),
+ body: FutureBuilder<Map<String, List<EnteFile>>>(
+ future: SearchService.instance
+ .getClusterFilesForPersonID(widget.person.remoteID),
builder: (context, snapshot) {
if (snapshot.hasData) {
final clusters = snapshot.data!;
- final List<int> keys = clusters.keys.toList();
+ final List<String> keys = clusters.keys.toList();
// Sort the clusters by the number of files in each cluster, largest first
keys.sort(
(b, a) => clusters[a]!.length.compareTo(clusters[b]!.length),
@@ -45,7 +46,7 @@ class _PersonClustersPageState extends State<PersonClustersPage> {
return ListView.builder(
itemCount: keys.length,
itemBuilder: (context, index) {
- final int clusterID = keys[index];
+ final String clusterID = keys[index];
final List<EnteFile> files = clusters[clusterID]!;
return InkWell(
onTap: () {
@@ -54,7 +55,7 @@ class _PersonClustersPageState extends State<PersonClustersPage> {
builder: (context) => ClusterPage(
files,
personID: widget.person,
- clusterID: index,
+ clusterID: clusterID,
showNamingBanner: false,
),
),
@@ -91,7 +92,8 @@ class _PersonClustersPageState extends State<PersonClustersPage> {
), // Add some spacing between the thumbnail and the text
Expanded(
child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8.0),
+ padding:
+ const EdgeInsets.symmetric(horizontal: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
@@ -103,14 +105,16 @@ class _PersonClustersPageState extends State<PersonClustersPage> {
? GestureDetector(
onTap: () async {
try {
- await PersonService.instance.removeClusterToPerson(
+ await PersonService.instance
+ .removeClusterToPerson(
personID: widget.person.remoteID,
clusterID: clusterID,
);
_logger.info(
"Removed cluster $clusterID from person ${widget.person.remoteID}",
);
- Bus.instance.fire(PeopleChangedEvent());
+ Bus.instance
+ .fire(PeopleChangedEvent());
setState(() {});
} catch (e) {
_logger.severe(
diff --git a/mobile/lib/ui/viewer/search/result/person_face_widget.dart b/mobile/lib/ui/viewer/search/result/person_face_widget.dart
index c63a8cd890..dda445b862 100644
--- a/mobile/lib/ui/viewer/search/result/person_face_widget.dart
+++ b/mobile/lib/ui/viewer/search/result/person_face_widget.dart
@@ -17,7 +17,7 @@ import "package:pool/pool.dart";
class PersonFaceWidget extends StatelessWidget {
final EnteFile file;
final String? personId;
- final int? clusterID;
+ final String? clusterID;
final bool useFullFile;
final bool thumbnailFallback;
final Uint8List? faceCrop;
diff --git a/mobile/lib/ui/viewer/search_tab/people_section.dart b/mobile/lib/ui/viewer/search_tab/people_section.dart
index 13e2f8a813..b3ce01045f 100644
--- a/mobile/lib/ui/viewer/search_tab/people_section.dart
+++ b/mobile/lib/ui/viewer/search_tab/people_section.dart
@@ -273,7 +273,7 @@ class SearchExample extends StatelessWidget {
onTap: () async {
final result = await showAssignPersonAction(
context,
- clusterID: int.parse(searchResult.name()),
+ clusterID: searchResult.name(),
);
if (result != null &&
result is (PersonEntity, EnteFile)) {