-
Notifications
You must be signed in to change notification settings - Fork 27.4k
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
Improved Documentation Of Audio Classification #35368
Changes from 2 commits
7aff33a
bf1b871
1bf6a06
e4c3e00
0d3a0d4
e18f932
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ Unless required by applicable law or agreed to in writing, software distributed | |
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations under the License. | ||
|
||
⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be | ||
⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be | ||
rendered properly in your Markdown viewer. | ||
|
||
--> | ||
|
@@ -20,7 +20,7 @@ rendered properly in your Markdown viewer. | |
|
||
<Youtube id="KWwzcmG98Ds"/> | ||
|
||
Audio classification - just like with text - assigns a class label output from the input data. The only difference is instead of text inputs, you have raw audio waveforms. Some practical applications of audio classification include identifying speaker intent, language classification, and even animal species by their sounds. | ||
Audio classification - just like with text - assigns a class label as output from the input data.. The only difference is instead of text inputs, you have raw audio waveforms. Some practical applications of audio classification include identifying speaker intent, language classification, and even animal species by their sounds. | ||
|
||
This guide will show you how to: | ||
|
||
|
@@ -57,7 +57,7 @@ Start by loading the MInDS-14 dataset from the 🤗 Datasets library: | |
>>> minds = load_dataset("PolyAI/minds14", name="en-US", split="train") | ||
``` | ||
|
||
Split the dataset's `train` split into a smaller train and test set with the [`~datasets.Dataset.train_test_split`] method. This'll give you a chance to experiment and make sure everything works before spending more time on the full dataset. | ||
Split the `train` split of the dataset into smaller train and test sets using the [`~datasets.Dataset.train_test_split`] method. This will give you a chance to experiment and make sure everything works before spending more time on the full dataset. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's necessary to change the first sentence, but good with |
||
|
||
```py | ||
>>> minds = minds.train_test_split(test_size=0.2) | ||
|
@@ -79,13 +79,13 @@ DatasetDict({ | |
}) | ||
``` | ||
|
||
While the dataset contains a lot of useful information, like `lang_id` and `english_transcription`, you'll focus on the `audio` and `intent_class` in this guide. Remove the other columns with the [`~datasets.Dataset.remove_columns`] method: | ||
While the dataset contains a lot of useful information, like `lang_id` and `english_transcription`, you will focus on the `audio` and `intent_class` in this guide. Remove the other columns with the [`~datasets.Dataset.remove_columns`] method: | ||
|
||
```py | ||
>>> minds = minds.remove_columns(["path", "transcription", "english_transcription", "lang_id"]) | ||
``` | ||
|
||
Take a look at an example now: | ||
Here's an example: | ||
|
||
```py | ||
>>> minds["train"][0] | ||
|
@@ -155,7 +155,7 @@ Now create a preprocessing function that: | |
... return inputs | ||
``` | ||
|
||
To apply the preprocessing function over the entire dataset, use 🤗 Datasets [`~datasets.Dataset.map`] function. You can speed up `map` by setting `batched=True` to process multiple elements of the dataset at once. Remove the columns you don't need, and rename `intent_class` to `label` because that's the name the model expects: | ||
To apply the preprocessing function over the entire dataset, use 🤗 Datasets [`~datasets.Dataset.map`] function. You can speed up `map` by setting `batched=True` to process multiple elements of the dataset at once. Remove unnecessary columns and rename `intent_class` to `label`, as required by the model: | ||
|
||
```py | ||
>>> encoded_minds = minds.map(preprocess_function, remove_columns="audio", batched=True) | ||
|
@@ -164,7 +164,7 @@ To apply the preprocessing function over the entire dataset, use 🤗 Datasets [ | |
|
||
## Evaluate | ||
|
||
Including a metric during training is often helpful for evaluating your model's performance. You can quickly load an evaluation method with the 🤗 [Evaluate](https://huggingface.co/docs/evaluate/index) library. For this task, load the [accuracy](https://huggingface.co/spaces/evaluate-metric/accuracy) metric (see the 🤗 Evaluate [quick tour](https://huggingface.co/docs/evaluate/a_quick_tour) to learn more about how to load and compute a metric): | ||
Including a metric during training can be helpful for evaluating your model's performance. You can quickly load an evaluation method with the 🤗 [Evaluate](https://huggingface.co/docs/evaluate/index) library. For this task, load the [accuracy](https://huggingface.co/spaces/evaluate-metric/accuracy) metric (see the 🤗 Evaluate [quick tour](https://huggingface.co/docs/evaluate/a_quick_tour) to learn more about how to load and compute a metric): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this change is necessary either; |
||
|
||
```py | ||
>>> import evaluate | ||
|
@@ -260,7 +260,7 @@ For a more in-depth example of how to fine-tune a model for audio classification | |
|
||
Great, now that you've fine-tuned a model, you can use it for inference! | ||
|
||
Load an audio file you'd like to run inference on. Remember to resample the sampling rate of the audio file to match the sampling rate of the model if you need to! | ||
Load an audio file for inference. Remember to resample the sampling rate of the audio file to match the model's sampling rate, if necessary. | ||
|
||
```py | ||
>>> from datasets import load_dataset, Audio | ||
|
@@ -271,7 +271,11 @@ Load an audio file you'd like to run inference on. Remember to resample the samp | |
>>> audio_file = dataset[0]["audio"]["path"] | ||
``` | ||
|
||
audio-classification | ||
To perform inference with your fine-tuned model, use a [pipeline]. Instantiate a `pipeline` for audio classification with your model, and pass your audio file to it: | ||
|
||
The simplest way to try out your fine-tuned model for inference is to use it in a [`pipeline`]. Instantiate a `pipeline` for audio classification with your model, and pass your audio file to it: | ||
main | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These additions also don't seem necessary (duplicate maybe?) |
||
|
||
```py | ||
>>> from transformers import pipeline | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.