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

resolve #379 audio classification evaluator + docs #405

Merged
merged 5 commits into from
Mar 14, 2023

Conversation

Plutone11011
Copy link
Contributor

This is the PR addressing #379.

For testing, I used the audio file highlighted in the Pipelines API example, mainly because the superb dataset requires manual download, which I felt was more cumbersome and less aligned with the other evaluators' tests.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

@lvwerra
Copy link
Member

lvwerra commented Jan 30, 2023

Looks awesome. Would you mind running make style && make quality such that the code quality tests pass?

@lvwerra lvwerra requested a review from lewtun February 1, 2023 13:22
@lvwerra
Copy link
Member

lvwerra commented Feb 1, 2023

Thanks a lot @Plutone11011 the PR looks very clean! I added @lewtun as a reviewer for the Audio specific part since he suggested this evaluator.

Copy link
Member

@lewtun lewtun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for adding this very clean implementation @Plutone11011 ! Overall it looks great - my only question is whether we should enable support for raw audio data since that would provide parity with the audio-classification pipeline

Would you like to extend your PR to support that?

>>> model_or_pipeline=""superb/wav2vec2-base-superb-ks"",
>>> data=data,
>>> label_column="label",
>>> input_column="file",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the audio-classification pipeline supports inference on both raw waveforms and audio files, would it make sense to enable support for both in evaluation?

In other words, input_column could be either an audio column of type np.ndarray or a file column of type str.

Also, if I'm not mistaken, using audio files requires ffmpeg to be installed - perhaps we should add a note somewhere in the example?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll add support for this.
Do you think it makes sense to also add a test for the dataset with audio column?

```python
>>> from evaluate import evaluator
>>> from datasets import load_dataset
>>> task_evaluator = evaluator("audio-classification")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: let's add a space between the imports and code

Suggested change
>>> task_evaluator = evaluator("audio-classification")
>>> task_evaluator = evaluator("audio-classification")

Audio classification evaluator.
This audio classification evaluator can currently be loaded from [`evaluator`] using the default task name
`audio-classification`.
Methods in this class assume a data format compatible with the [`AudioClassificationPipeline`].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
Methods in this class assume a data format compatible with the [`AudioClassificationPipeline`].
Methods in this class assume a data format compatible with the [`transformers.AudioClassificationPipeline`].

n_resamples: int = 9999,
device: int = None,
random_state: Optional[int] = None,
input_column: str = "file",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment about about extending this to support raw waveforms in an audio column

@Plutone11011
Copy link
Contributor Author

Plutone11011 commented Feb 6, 2023

@lewtun I made the changes. In the docs example I added a map operation to rearrange the dataset to be consistent with what the evaluator and pipeline expect, since usually audio datasets have an Audio column that looks like this

"audio": {
     'array': array([...], dtype=float32),
     'path': 'path/to/audio_1',
     'sampling_rate': 16000
}

EDIT:
sorry must have synced on this branch and included other commits in main

Copy link
Member

@lvwerra lvwerra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me :) I think the other commits will go away when we squash-merge the PR.

@lvwerra lvwerra merged commit a25b47b into huggingface:main Mar 14, 2023
unna97 pushed a commit to unna97/evaluate that referenced this pull request Mar 20, 2023
…gface#405)

* audio classification evaluator + docs

* fix styling issue

* [Docs] fixed a typo in bertscore readme (huggingface#386)

fixed typo in berscore readme

* Add max_length kwarg to docstring of Perplexity measurement (huggingface#411)

Added max_length kwarg to docstring of Perplexity measurement

* adding support raw audio input audio classification evaluator

---------

Co-authored-by: Hazrul Akmal <hazrulakmal121@gmail.com>
Co-authored-by: Kalyan Dutia <kalyan.dutia@gmail.com>
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

Successfully merging this pull request may close these issues.

None yet

6 participants