mistermprah commited on
Commit
b8c55dd
1 Parent(s): bc6c98d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
- import torchaudio
4
  from config import MODEL_ID
5
 
6
  # Load the model and pipeline using the model_id variable
@@ -39,15 +38,18 @@ if uploaded_file is not None:
39
  results_str = "\n".join([f"{label}: {score:.2f}" for label, score in results.items()])
40
  results_box.text(results_str)
41
 
42
- # Examples of audio files for classification
43
- st.write("Examples:")
44
  examples = ['normal.wav', 'murmur.wav', 'extra_systole.wav', 'extra_hystole.wav', 'artifact.wav']
45
- for example in examples:
46
- if st.button(example):
47
- st.subheader(f"Example: {example}")
 
 
 
48
  audio_bytes = open(example, 'rb').read()
49
- st.audio(audio_bytes, format='audio/wav')
50
  results = classify_audio(example)
51
- st.write("Results:")
52
- results_str = "\n".join([f"{label}: {score:.4f}" for label, score in results.items()])
53
- st.text(results_str)
 
1
  import streamlit as st
2
  from transformers import pipeline
 
3
  from config import MODEL_ID
4
 
5
  # Load the model and pipeline using the model_id variable
 
38
  results_str = "\n".join([f"{label}: {score:.2f}" for label, score in results.items()])
39
  results_box.text(results_str)
40
 
41
+ # Audio Test Samples for classification
42
+ st.write("Audio Test Samples:")
43
  examples = ['normal.wav', 'murmur.wav', 'extra_systole.wav', 'extra_hystole.wav', 'artifact.wav']
44
+ cols = st.columns(3)
45
+
46
+ for idx, example in enumerate(examples):
47
+ col = cols[idx % 3] # Rotate columns for better arrangement
48
+ if col.button(example):
49
+ col.subheader(f"Sample Audio: {example}")
50
  audio_bytes = open(example, 'rb').read()
51
+ col.audio(audio_bytes, format='audio/wav')
52
  results = classify_audio(example)
53
+ col.write("Results:")
54
+ results_str = "\n".join([f"{label}: {score:.2f}" for label, score in results.items()])
55
+ col.text(results_str)