mirror of
https://github.com/ente-io/ente.git
synced 2025-08-10 16:32:39 +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 bool? badFace;
|
||||||
final Vector? vEmbedding;
|
final Vector? vEmbedding;
|
||||||
String? clusterId;
|
String? clusterId;
|
||||||
|
final List<String>? rejectedClusterIds;
|
||||||
String? closestFaceId;
|
String? closestFaceId;
|
||||||
int? closestDist;
|
int? closestDist;
|
||||||
int? fileCreationTime;
|
int? fileCreationTime;
|
||||||
@ -32,6 +33,7 @@ class FaceInfo {
|
|||||||
this.badFace,
|
this.badFace,
|
||||||
this.vEmbedding,
|
this.vEmbedding,
|
||||||
this.clusterId,
|
this.clusterId,
|
||||||
|
this.rejectedClusterIds,
|
||||||
this.fileCreationTime,
|
this.fileCreationTime,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -328,6 +330,7 @@ ClusteringResult runLinearClustering(Map args) {
|
|||||||
dtype: DType.float32,
|
dtype: DType.float32,
|
||||||
),
|
),
|
||||||
clusterId: face.clusterId,
|
clusterId: face.clusterId,
|
||||||
|
rejectedClusterIds: face.rejectedClusterIds,
|
||||||
fileCreationTime:
|
fileCreationTime:
|
||||||
fileIDToCreationTime?[getFileIdFromFaceId(face.faceID)],
|
fileIDToCreationTime?[getFileIdFromFaceId(face.faceID)],
|
||||||
),
|
),
|
||||||
@ -372,7 +375,6 @@ ClusteringResult runLinearClustering(Map args) {
|
|||||||
_logger.info(
|
_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" : ""}",
|
"[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();
|
String clusterID = newClusterID();
|
||||||
if (facesWithClusterID.isEmpty) {
|
if (facesWithClusterID.isEmpty) {
|
||||||
// assign a clusterID to the first face
|
// assign a clusterID to the first face
|
||||||
@ -398,6 +400,7 @@ ClusteringResult runLinearClustering(Map args) {
|
|||||||
} else {
|
} else {
|
||||||
thresholdValue = distanceThreshold;
|
thresholdValue = distanceThreshold;
|
||||||
}
|
}
|
||||||
|
final bool faceHasBeenRejectedBefore = sortedFaceInfos[i].rejectedClusterIds != null;
|
||||||
if (i % 250 == 0) {
|
if (i % 250 == 0) {
|
||||||
_logger.info("Processed ${offset != null ? i + offset : i} faces");
|
_logger.info("Processed ${offset != null ? i + offset : i} faces");
|
||||||
}
|
}
|
||||||
@ -410,6 +413,13 @@ ClusteringResult runLinearClustering(Map args) {
|
|||||||
distance > conservativeDistanceThreshold) {
|
distance > conservativeDistanceThreshold) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (faceHasBeenRejectedBefore &&
|
||||||
|
sortedFaceInfos[j].clusterId != null &&
|
||||||
|
sortedFaceInfos[i].rejectedClusterIds!.contains(
|
||||||
|
sortedFaceInfos[j].clusterId!,
|
||||||
|
)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
closestDistance = distance;
|
closestDistance = distance;
|
||||||
closestIdx = j;
|
closestIdx = j;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import "dart:typed_data" show Uint8List;
|
|||||||
class FaceDbInfoForClustering {
|
class FaceDbInfoForClustering {
|
||||||
final String faceID;
|
final String faceID;
|
||||||
String? clusterId;
|
String? clusterId;
|
||||||
|
List<String>? rejectedClusterIds;
|
||||||
final Uint8List embeddingBytes;
|
final Uint8List embeddingBytes;
|
||||||
final double faceScore;
|
final double faceScore;
|
||||||
final double blurValue;
|
final double blurValue;
|
||||||
|
@ -250,6 +250,19 @@ class MLService {
|
|||||||
|
|
||||||
_logger.info('Pulling remote feedback before actually clustering');
|
_logger.info('Pulling remote feedback before actually clustering');
|
||||||
await PersonService.instance.fetchRemoteClusterFeedback();
|
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 {
|
try {
|
||||||
_showClusteringIsHappening = true;
|
_showClusteringIsHappening = true;
|
||||||
@ -271,6 +284,9 @@ class MLService {
|
|||||||
if (!fileIDToCreationTime.containsKey(faceInfo.fileID)) {
|
if (!fileIDToCreationTime.containsKey(faceInfo.fileID)) {
|
||||||
missingFileIDs.add(faceInfo.fileID);
|
missingFileIDs.add(faceInfo.fileID);
|
||||||
} else {
|
} else {
|
||||||
|
if (faceIdNotToCluster.containsKey(faceInfo.faceID)) {
|
||||||
|
faceInfo.rejectedClusterIds = faceIdNotToCluster[faceInfo.faceID];
|
||||||
|
}
|
||||||
allFaceInfoForClustering.add(faceInfo);
|
allFaceInfoForClustering.add(faceInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user