Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Expected argument task to either be 'binary', 'multiclass' or 'multilabel' but got 1 #1242

Closed
saadtariq-ds opened this issue Jan 27, 2023 · 11 comments

Comments

@saadtariq-ds
Copy link

vad_task = VoiceActivityDetection(ami, duration=2., batch_size=128)
vad_model = PyanNet(task=vad_task, sincnet={'stride': 10})
trainer = pl.Trainer(gpus=self.gpus, max_epochs=self.max_epochs)
trainer.fit(vad_model)

@waoooNiuBility
Copy link

I've met the question as you too,How did you solve it

@kaleaniket
Copy link

kaleaniket commented Mar 1, 2023

I'm also getting the same error on Colab, Is there any fix to this?

@saadtariq-ds
Copy link
Author

I solved by downgrading torchmetrics version. Current version torchmetrics==0.10.3

@kaleaniket
Copy link

I solved by downgrading torchmetrics version. Current version torchmetrics==0.10.3

Thanks. It worked for me as well.

@toto6038
Copy link

toto6038 commented Mar 2, 2023

So it looks like there's a breaking change on torchmetrics' API (AUROC.__new__ in .../miniconda3/envs/pyannote/lib/python3.8/site-packages/torchmetrics/classification/auroc.py). Downgrading torchmetrics may serve as a workaround, but Pyannote has to adapt to the new API eventually.

@hbredin
Copy link
Member

hbredin commented Mar 2, 2023

but Pyannote has to adapt to the new API eventually.

Yes, indeed. Feel free to contribute this "adaptation" via a pull request.

@toto6038
Copy link

toto6038 commented Mar 3, 2023

but Pyannote has to adapt to the new API eventually.

Yes, indeed. Feel free to contribute this "adaptation" via a pull request.

I'll do it

@saadtariq-ds
Copy link
Author

Thanks everyone

@hbredin
Copy link
Member

hbredin commented Mar 3, 2023

Re-opening the issue until @toto6038's PR fixes it.
Thanks @toto6038 ;-)

@hbredin hbredin reopened this Mar 3, 2023
@toto6038
Copy link

toto6038 commented Mar 4, 2023

Edit

Related PR: #1181

TL;DR

A release of minor update is enough to avoid the problem as the solution has been done already.

Detail

After some investigation to the source code, it looks like the existing code has already mitigated the problem and therefore there will be no PR. To better explain the cause of problem, we first examine the version of Pyannote that users get from pip:

def default_metric(
self,
) -> Union[Metric, Sequence[Metric], Dict[str, Metric]]:
"""Returns macro-average of the area under the ROC curve"""
num_classes = len(self.specifications.classes)
return AUROC(num_classes, pos_label=1, average="macro", compute_on_step=False)

It's the change of the interface of AUROC's __new__() that results in the ValueError issue.

The latest code in develop branch has done similar work as that in torchmetrics to return different object depending on the type of the task.

if self.specifications.problem == Problem.BINARY_CLASSIFICATION:
return BinaryAUROC(compute_on_cpu=True)
elif self.specifications.problem == Problem.MULTI_LABEL_CLASSIFICATION:
return MultilabelAUROC(num_classes, average="macro", compute_on_cpu=True)
elif self.specifications.problem == Problem.MONO_LABEL_CLASSIFICATION:
return MulticlassAUROC(num_classes, average="macro", compute_on_cpu=True)
else:
raise RuntimeError(
f"The {self.specifications.problem} problem type hasn't been given a default segmentation metric yet."
)

@hbredin
Copy link
Member

hbredin commented Mar 5, 2023

Oh! Thanks @toto6038 :-)

To anyone encountering the same issue, and until this fix has been released, please install pyannote.audio from develop branch (where the issue has been fixed already).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants