Spaces:
Sleeping
Sleeping
Commit
·
e7b15aa
1
Parent(s):
96fc794
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,13 +17,6 @@ pipe = pipeline("audio-classification", model=model_id, device=device)
|
|
| 17 |
|
| 18 |
|
| 19 |
def classify_audio(filepath):
|
| 20 |
-
"""
|
| 21 |
-
Goes from
|
| 22 |
-
[{'score': 0.8339303731918335, 'label': 'country'},
|
| 23 |
-
{'score': 0.11914275586605072, 'label': 'rock'},]
|
| 24 |
-
to
|
| 25 |
-
{"country": 0.8339303731918335, "rock":0.11914275586605072}
|
| 26 |
-
"""
|
| 27 |
import time
|
| 28 |
start_time = time.time()
|
| 29 |
|
|
@@ -39,6 +32,7 @@ def classify_audio(filepath):
|
|
| 39 |
|
| 40 |
return outputs, prediction_time
|
| 41 |
|
|
|
|
| 42 |
title = "🎵 Music Genre Classifier"
|
| 43 |
description = """
|
| 44 |
Music Genre Classifier model (Fine-tuned "ntu-spml/distilhubert") Dataset: [GTZAN](https://huggingface.co/datasets/marsyas/gtzan)
|
|
@@ -46,10 +40,11 @@ Music Genre Classifier model (Fine-tuned "ntu-spml/distilhubert") Dataset: [GTZA
|
|
| 46 |
|
| 47 |
filenames = ['rock-it-21275.mp3']
|
| 48 |
filenames = [f"./{f}" for f in filenames]
|
|
|
|
| 49 |
demo = gr.Interface(
|
| 50 |
fn=classify_audio,
|
| 51 |
inputs=gr.Audio(type="filepath"),
|
| 52 |
-
outputs=[gr.
|
| 53 |
title=title,
|
| 54 |
description=description,
|
| 55 |
examples=[(f,) for f in filenames],
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
def classify_audio(filepath):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
import time
|
| 21 |
start_time = time.time()
|
| 22 |
|
|
|
|
| 32 |
|
| 33 |
return outputs, prediction_time
|
| 34 |
|
| 35 |
+
|
| 36 |
title = "🎵 Music Genre Classifier"
|
| 37 |
description = """
|
| 38 |
Music Genre Classifier model (Fine-tuned "ntu-spml/distilhubert") Dataset: [GTZAN](https://huggingface.co/datasets/marsyas/gtzan)
|
|
|
|
| 40 |
|
| 41 |
filenames = ['rock-it-21275.mp3']
|
| 42 |
filenames = [f"./{f}" for f in filenames]
|
| 43 |
+
|
| 44 |
demo = gr.Interface(
|
| 45 |
fn=classify_audio,
|
| 46 |
inputs=gr.Audio(type="filepath"),
|
| 47 |
+
outputs=[gr.Label(), gr.Number(label="Prediction time (s)")], # Using updated component names
|
| 48 |
title=title,
|
| 49 |
description=description,
|
| 50 |
examples=[(f,) for f in filenames],
|