From 5f9d416daec41e30dc3ebc30b803ac1ba792d308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20BREDIN?= Date: Wed, 7 Sep 2022 22:48:53 +0200 Subject: [PATCH] fix: fix corner case with noisy samples only --- pyannote/audio/pipelines/clustering.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyannote/audio/pipelines/clustering.py b/pyannote/audio/pipelines/clustering.py index 92550f02..5bd9a019 100644 --- a/pyannote/audio/pipelines/clustering.py +++ b/pyannote/audio/pipelines/clustering.py @@ -450,6 +450,9 @@ class DBSCANClustering(BaseClustering): ) num_clusters = np.max(clusters) + 1 + if num_clusters < 1: + return np.zeros((num_embeddings,), dtype=np.uint8) + # assign noisy samples to closest centroid centroids = np.vstack( [np.mean(embeddings[clusters == k], axis=0) for k in range(num_clusters)]