From eb92e79fb94e7b3df8f27c8ce3e607a70dff2a2e Mon Sep 17 00:00:00 2001
From: 语帆 <yf352572@alibaba-inc.com>
Date: 星期三, 28 二月 2024 15:21:32 +0800
Subject: [PATCH] test

---
 funasr/models/campplus/cluster_backend.py |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/funasr/models/campplus/cluster_backend.py b/funasr/models/campplus/cluster_backend.py
index 47b45d2..72d06da 100644
--- a/funasr/models/campplus/cluster_backend.py
+++ b/funasr/models/campplus/cluster_backend.py
@@ -1,14 +1,16 @@
-# Copyright (c) Alibaba, Inc. and its affiliates.
+#!/usr/bin/env python3
+# -*- encoding: utf-8 -*-
+# Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved.
+#  MIT License  (https://opensource.org/licenses/MIT)
+# Modified from 3D-Speaker (https://github.com/alibaba-damo-academy/3D-Speaker)
 
-from typing import Any, Dict, Union
-
+import scipy
+import torch
+import sklearn
 import hdbscan
 import numpy as np
-import scipy
-import sklearn
-import umap
+
 from sklearn.cluster._kmeans import k_means
-from torch import nn
 
 
 class SpectralCluster:
@@ -116,6 +118,7 @@
         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,
@@ -129,7 +132,7 @@
         return labels
 
 
-class ClusterBackend(nn.Module):
+class ClusterBackend(torch.nn.Module):
     r"""Perfom clustering for input embeddings and output the labels.
     Args:
         model_dir: A model dir.
@@ -153,6 +156,7 @@
         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)

--
Gitblit v1.9.1