azeus commited on
Commit
b6a2312
·
1 Parent(s): 7b63dbd

Add application file

Browse files
Files changed (1) hide show
  1. app.py +6 -50
app.py CHANGED
@@ -1,55 +1,11 @@
1
  import streamlit as st
2
- import numpy as np
3
- import pandas as pd
4
- import io
5
 
6
- # Page config
7
- st.set_page_config(page_title="AI Music Genre Classifier", layout="wide")
8
 
9
- # Initialize session state
10
- if 'history' not in st.session_state:
11
- st.session_state.history = []
12
 
 
13
 
14
- def main():
15
- st.title("🎵 AI Music Genre Classifier")
16
-
17
- # File uploader
18
- audio_file = st.file_uploader("Upload an audio file (MP3, WAV)", type=['mp3', 'wav'])
19
-
20
- if audio_file is not None:
21
- st.audio(audio_file)
22
-
23
- # Simulate genre classification
24
- genres = ['Rock', 'Pop', 'Hip Hop', 'Classical', 'Jazz']
25
- predictions = np.random.dirichlet(np.ones(len(genres)))
26
-
27
- # Display predictions
28
- st.header("Genre Predictions:")
29
-
30
- # Create simple bar chart using streamlit
31
- genre_df = pd.DataFrame({
32
- 'Genre': genres,
33
- 'Confidence': predictions
34
- })
35
- st.bar_chart(genre_df.set_index('Genre'))
36
-
37
- # Save to history
38
- top_genre = genres[np.argmax(predictions)]
39
- confidence = np.max(predictions)
40
-
41
- st.session_state.history.append({
42
- 'File': audio_file.name,
43
- 'Predicted Genre': top_genre,
44
- 'Confidence': f"{confidence:.2%}"
45
- })
46
-
47
- # History section
48
- if st.session_state.history:
49
- st.header("Classification History:")
50
- history_df = pd.DataFrame(st.session_state.history)
51
- st.dataframe(history_df)
52
-
53
-
54
- if __name__ == "__main__":
55
- main()
 
1
  import streamlit as st
 
 
 
2
 
3
+ st.title("🎵 Music Genre Classifier")
 
4
 
5
+ st.write("Basic test to verify app is working")
 
 
6
 
7
+ audio_file = st.file_uploader("Upload an audio file (MP3, WAV)", type=['mp3', 'wav'])
8
 
9
+ if audio_file is not None:
10
+ st.audio(audio_file)
11
+ st.write("File uploaded successfully!")