marsyas/gtzan
Updated • 2.81k • 18
How to use anthony-wss/distilhubert-finetuned-gtzan with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("audio-classification", model="anthony-wss/distilhubert-finetuned-gtzan") # Load model directly
from transformers import AutoProcessor, AutoModelForAudioClassification
processor = AutoProcessor.from_pretrained("anthony-wss/distilhubert-finetuned-gtzan")
model = AutoModelForAudioClassification.from_pretrained("anthony-wss/distilhubert-finetuned-gtzan", device_map="auto")This repo contains code and notes for this tutorial.
GTZAN is used.
export HUGGINGFACE_TOKEN=<your_token>
python main.py
Acc: 0.81 (default setting)
🤗 Datasets support train_test_split() method to split the dataset.
feature_extractor can not handle resampling
dataset.map()from datasets import Audio
gtzan = gtzan.cast_column("audio", Audio(sampling_rate=feature_extractor.sampling_rate))
feature_extractor do the normalization and returns input_values and attention_mask.
.map() support batched preprocess.
Why AutoModelForAudioClassification.from_pretrained takes label2id and id2label?