Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,10 +8,16 @@ pipe = pipeline("audio-classification", model=MODEL_ID)
|
|
| 8 |
|
| 9 |
def classify_audio(filepath):
|
| 10 |
preds = pipe(filepath)
|
| 11 |
-
outputs = {}
|
| 12 |
for p in preds:
|
| 13 |
-
label = p["label"]
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
return outputs
|
| 16 |
|
| 17 |
# Streamlit app layout
|
|
|
|
| 8 |
|
| 9 |
def classify_audio(filepath):
|
| 10 |
preds = pipe(filepath)
|
| 11 |
+
outputs = {"normal": 0.0, "artifact": 0.0, "murmur": 0.0}
|
| 12 |
for p in preds:
|
| 13 |
+
label = p["label"]
|
| 14 |
+
# Simplify the labels and accumulate the scores
|
| 15 |
+
if "artifact" in label:
|
| 16 |
+
outputs["artifact"] += p["score"]
|
| 17 |
+
elif "murmur" in label:
|
| 18 |
+
outputs["murmur"] += p["score"]
|
| 19 |
+
elif "extra" in label or "normal" in label:
|
| 20 |
+
outputs["normal"] += p["score"]
|
| 21 |
return outputs
|
| 22 |
|
| 23 |
# Streamlit app layout
|