fix app.py
Browse files
app.py
CHANGED
|
@@ -5,22 +5,18 @@ from transformers import pipeline
|
|
| 5 |
pipe_gtzan = pipeline(
|
| 6 |
"audio-classification",
|
| 7 |
model="sanchit-gandhi/distilhubert-finetuned-gtzan",
|
| 8 |
-
device="cpu",
|
| 9 |
)
|
| 10 |
|
| 11 |
pipe_esc = pipeline(
|
| 12 |
"audio-classification",
|
| 13 |
model="sonicase/distilhubert-finetuned-esc50",
|
| 14 |
-
device="cpu",
|
| 15 |
)
|
| 16 |
|
| 17 |
|
| 18 |
@spaces.GPU
|
| 19 |
def classify(filepath):
|
| 20 |
-
pipe_gtzan
|
| 21 |
-
pipe_esc
|
| 22 |
-
genre = pipe_gtzan(filepath)
|
| 23 |
-
env = pipe_esc(filepath)
|
| 24 |
return (
|
| 25 |
{p["label"]: p["score"] for p in genre},
|
| 26 |
{p["label"]: p["score"] for p in env},
|
|
|
|
| 5 |
pipe_gtzan = pipeline(
|
| 6 |
"audio-classification",
|
| 7 |
model="sanchit-gandhi/distilhubert-finetuned-gtzan",
|
|
|
|
| 8 |
)
|
| 9 |
|
| 10 |
pipe_esc = pipeline(
|
| 11 |
"audio-classification",
|
| 12 |
model="sonicase/distilhubert-finetuned-esc50",
|
|
|
|
| 13 |
)
|
| 14 |
|
| 15 |
|
| 16 |
@spaces.GPU
|
| 17 |
def classify(filepath):
|
| 18 |
+
genre = pipe_gtzan(filepath, device="cuda")
|
| 19 |
+
env = pipe_esc(filepath, device="cuda")
|
|
|
|
|
|
|
| 20 |
return (
|
| 21 |
{p["label"]: p["score"] for p in genre},
|
| 22 |
{p["label"]: p["score"] for p in env},
|