Commit
·
d26bd2a
1
Parent(s):
71ce89a
update model loading parameters for bird sound classification
Browse files
app.py
CHANGED
@@ -3,12 +3,15 @@ import torch
|
|
3 |
import librosa
|
4 |
from transformers import Wav2Vec2ForSequenceClassification, Wav2Vec2FeatureExtractor
|
5 |
|
6 |
-
# Load model from Hugging Face Hub
|
7 |
model_name = "greenarcade/wav2vec2-vd-bird-sound-classification"
|
8 |
-
model = Wav2Vec2ForSequenceClassification.from_pretrained(
|
|
|
|
|
|
|
|
|
|
|
9 |
feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained(model_name)
|
10 |
|
11 |
-
|
12 |
def predict(audio_file):
|
13 |
# Handle MP3/WAV files
|
14 |
audio, sr = librosa.load(audio_file, sr=16000)
|
|
|
3 |
import librosa
|
4 |
from transformers import Wav2Vec2ForSequenceClassification, Wav2Vec2FeatureExtractor
|
5 |
|
|
|
6 |
model_name = "greenarcade/wav2vec2-vd-bird-sound-classification"
|
7 |
+
model = Wav2Vec2ForSequenceClassification.from_pretrained(
|
8 |
+
model_name,
|
9 |
+
local_files_only=False,
|
10 |
+
use_auth_token=None,
|
11 |
+
trust_remote_code=False
|
12 |
+
)
|
13 |
feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained(model_name)
|
14 |
|
|
|
15 |
def predict(audio_file):
|
16 |
# Handle MP3/WAV files
|
17 |
audio, sr = librosa.load(audio_file, sr=16000)
|