Skip to content

Commit

Permalink
fix face cluster (#447)
Browse files Browse the repository at this point in the history
Co-authored-by: zheng.shen <[email protected]>
  • Loading branch information
shenzheng-1 and zheng.shen authored Dec 25, 2024
1 parent 853a5bc commit 54a0e17
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions face_recognition/face_recognition_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,20 @@ def face_cluster(self, repo_id):

culstered_rows, unclustered_rows = get_faces_rows(repo_id, self.metadata_server_api)
min_cluster_size = get_min_cluster_size(len(vectors))
clt = HDBSCAN(min_cluster_size=min_cluster_size)
clt.fit(vectors)
if len(vectors) < min_cluster_size:
clt_labels = [-1] * len(vectors)
else:
clt = HDBSCAN(min_cluster_size=min_cluster_size)
clt.fit(vectors)
clt_labels = clt.labels_

cluster_id_to_min_distance = {}
label_id_to_added_cluster = {}
label_id_to_updated_cluster = {}
cluster_id_to_label = {}
label_ids = np.unique(clt.labels_)
label_ids = np.unique(clt_labels)
for label_id in label_ids:
idxs = np.where(clt.labels_ == label_id)[0]
idxs = np.where(clt_labels == label_id)[0]
related_row_ids = [row_ids[i] for i in idxs]

if label_id == -1:
Expand Down

0 comments on commit 54a0e17

Please sign in to comment.