mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
[mob][photos] Dont recluster rejected face to cluster mapping
This commit is contained in:
parent
4c222f2cd7
commit
5d99a7c757
@ -22,6 +22,7 @@ class FaceInfo {
|
||||
final bool? badFace;
|
||||
final Vector? vEmbedding;
|
||||
String? clusterId;
|
||||
final List<String>? rejectedClusterIds;
|
||||
String? closestFaceId;
|
||||
int? closestDist;
|
||||
int? fileCreationTime;
|
||||
@ -32,6 +33,7 @@ class FaceInfo {
|
||||
this.badFace,
|
||||
this.vEmbedding,
|
||||
this.clusterId,
|
||||
this.rejectedClusterIds,
|
||||
this.fileCreationTime,
|
||||
});
|
||||
}
|
||||
@ -328,6 +330,7 @@ ClusteringResult runLinearClustering(Map args) {
|
||||
dtype: DType.float32,
|
||||
),
|
||||
clusterId: face.clusterId,
|
||||
rejectedClusterIds: face.rejectedClusterIds,
|
||||
fileCreationTime:
|
||||
fileIDToCreationTime?[getFileIdFromFaceId(face.faceID)],
|
||||
),
|
||||
@ -372,7 +375,6 @@ ClusteringResult runLinearClustering(Map args) {
|
||||
_logger.info(
|
||||
"[ClusterIsolate] ${DateTime.now()} Processing $totalFaces faces ($newToClusterCount new, $alreadyClusteredCount already done) in total in this round ${offset != null ? "on top of ${offset + facesWithClusterID.length} earlier processed faces" : ""}",
|
||||
);
|
||||
// set current epoch time as clusterID
|
||||
String clusterID = newClusterID();
|
||||
if (facesWithClusterID.isEmpty) {
|
||||
// assign a clusterID to the first face
|
||||
@ -398,6 +400,7 @@ ClusteringResult runLinearClustering(Map args) {
|
||||
} else {
|
||||
thresholdValue = distanceThreshold;
|
||||
}
|
||||
final bool faceHasBeenRejectedBefore = sortedFaceInfos[i].rejectedClusterIds != null;
|
||||
if (i % 250 == 0) {
|
||||
_logger.info("Processed ${offset != null ? i + offset : i} faces");
|
||||
}
|
||||
@ -410,6 +413,13 @@ ClusteringResult runLinearClustering(Map args) {
|
||||
distance > conservativeDistanceThreshold) {
|
||||
continue;
|
||||
}
|
||||
if (faceHasBeenRejectedBefore &&
|
||||
sortedFaceInfos[j].clusterId != null &&
|
||||
sortedFaceInfos[i].rejectedClusterIds!.contains(
|
||||
sortedFaceInfos[j].clusterId!,
|
||||
)) {
|
||||
continue;
|
||||
}
|
||||
closestDistance = distance;
|
||||
closestIdx = j;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import "dart:typed_data" show Uint8List;
|
||||
class FaceDbInfoForClustering {
|
||||
final String faceID;
|
||||
String? clusterId;
|
||||
List<String>? rejectedClusterIds;
|
||||
final Uint8List embeddingBytes;
|
||||
final double faceScore;
|
||||
final double blurValue;
|
||||
|
@ -250,6 +250,19 @@ class MLService {
|
||||
|
||||
_logger.info('Pulling remote feedback before actually clustering');
|
||||
await PersonService.instance.fetchRemoteClusterFeedback();
|
||||
final persons = await PersonService.instance.getPersons();
|
||||
final faceIdNotToCluster = <String, List<String>>{};
|
||||
for (final person in persons) {
|
||||
if (person.data.rejectedFaceIDs != null &&
|
||||
person.data.rejectedFaceIDs!.isNotEmpty) {
|
||||
final personClusters = person.data.assigned?.map((e) => e.id).toList();
|
||||
if (personClusters != null) {
|
||||
for (final faceID in person.data.rejectedFaceIDs!) {
|
||||
faceIdNotToCluster[faceID] = personClusters;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
_showClusteringIsHappening = true;
|
||||
@ -271,6 +284,9 @@ class MLService {
|
||||
if (!fileIDToCreationTime.containsKey(faceInfo.fileID)) {
|
||||
missingFileIDs.add(faceInfo.fileID);
|
||||
} else {
|
||||
if (faceIdNotToCluster.containsKey(faceInfo.faceID)) {
|
||||
faceInfo.rejectedClusterIds = faceIdNotToCluster[faceInfo.faceID];
|
||||
}
|
||||
allFaceInfoForClustering.add(faceInfo);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user