| | |
| | | # MIT License (https://opensource.org/licenses/MIT) |
| | | # Modified from 3D-Speaker (https://github.com/alibaba-damo-academy/3D-Speaker) |
| | | |
| | | import umap |
| | | import scipy |
| | | import torch |
| | | import sklearn |
| | |
| | | self.metric = metric |
| | | |
| | | def __call__(self, X): |
| | | import umap.umap_ as umap |
| | | umap_X = umap.UMAP( |
| | | n_neighbors=self.n_neighbors, |
| | | min_dist=0.0, |
| | |
| | | if X.shape[0] < 20: |
| | | return np.zeros(X.shape[0], dtype='int') |
| | | if X.shape[0] < 2048 or k is not None: |
| | | # unexpected corner case |
| | | labels = self.spectral_cluster(X, k) |
| | | else: |
| | | labels = self.umap_hdbscan_cluster(X) |