From d95ad76e9b7aad16ea607c1570cb0511eba434d6 Mon Sep 17 00:00:00 2001 From: Hans Azilinon Date: Mon, 16 Nov 2026 16:36:23 +0100 Subject: [PATCH] fix(campplus): convert torch.Tensor input to NumPy before passing to UMAP UMAP 0.6.0 calls np.issubdtype on the input dtype during fit_transform, which raises TypeError when given a torch.Tensor directly. The fix ensures the input is always a NumPy array by calling .detach().cpu().numpy() for tensors, matching the type of embedding data from auto_model.forward(). --- funasr/models/campplus/cluster_backend.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/funasr/models/campplus/cluster_backend.py b/funasr/models/campplus/cluster_backend.py index e6c4ca64d..8bb84ab41 100644 --- a/funasr/models/campplus/cluster_backend.py +++ b/funasr/models/campplus/cluster_backend.py @@ -254,6 +254,10 @@ def forward(self, X, **params): X: TODO. **params: Additional keyword arguments. """ + # Normalize the input once so UMAP and the later centroid operations + # receive a NumPy array. Passing a torch.Tensor here makes UMAP 0.6.0 + # raise TypeError: Cannot interpret 'torch.float32' as a data type. + X = X.detach().cpu().numpy() if isinstance(X, torch.Tensor) else np.asarray(X) k = params["oracle_num"] if "oracle_num" in params else None assert len(X.shape) == 2, "modelscope error: the shape of input should be [N, C]" if X.shape[0] < 20: