wq2012 / SpectralCluster

Python re-implementation of the (constrained) spectral clustering algorithms used in Google's speaker diarization papers.
https://google.github.io/speaker-id/publications/LstmDiarization/
Apache License 2.0
513 stars 73 forks source link

TypeError: constraint matrix must be a numpy array #46

Closed imohitmayank closed 2 years ago

imohitmayank commented 2 years ago

configs.turntodiarize_clusterer is giving TypeError: constraint matrix must be a numpy array error for a data on which icassp2018_clusterer is working fine.

Error log:

File /..../spectralcluster/spectral_clusterer.py:250, in SpectralClusterer.predict(self, embeddings, constraint_matrix)
    246 # Apply constraint.
    247 if (self.constraint_options and
    248     self.constraint_options.apply_before_refinement):
    249   # Perform the constraint operation before refinement
--> 250   affinity = self.constraint_options.constraint_operator.adjust_affinity(
    251       affinity, constraint_matrix)
    253 if self.autotune:
    254   # Use Auto-tuning method to find a good p_percentile.
    255   if (RefinementName.RowWiseThreshold
    256       not in self.refinement_options.refinement_sequence):
...
---> 77   raise TypeError("constraint matrix must be a numpy array")
     78 if len(affinity.shape) != 2:
     79   raise ValueError("affinity must be 2-dimensional")

TypeError: constraint matrix must be a numpy array

Is there some different format or conditions on the input for turntodiarize_clusterer?

wq2012 commented 2 years ago

turntodiarize_clusterer is for constrained clustering. What is your constraint here?

wq2012 commented 2 years ago

I have updated the code to allow not setting constraints.