Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,15 +7,9 @@ import pandas as pd
|
|
7 |
from sklearn.neighbors import NearestNeighbors
|
8 |
from sklearn.preprocessing import StandardScaler
|
9 |
|
10 |
-
# Load the LSTM model for emotion prediction
|
11 |
-
emotion_model = load_model('lstm_model.h5')
|
12 |
-
|
13 |
# Load the KNN model
|
14 |
knn_model = joblib.load('knn_model.joblib')
|
15 |
|
16 |
-
# Load the tokenizer
|
17 |
-
tokenizer = joblib.load('tokenizer.pkl')
|
18 |
-
|
19 |
# Load the dataset
|
20 |
df = pd.read_csv('df1.csv')
|
21 |
|
@@ -48,19 +42,8 @@ st.title('KNN Recommender App')
|
|
48 |
# Get song index from user input
|
49 |
song_index_to_recommend = st.number_input('Enter song index:', min_value=0, max_value=len(df)-1, value=0)
|
50 |
|
51 |
-
# Get lyrics for emotion prediction
|
52 |
-
lyrics = df.iloc[song_index_to_recommend]['lyrics']
|
53 |
-
|
54 |
-
# Process the lyrics
|
55 |
-
sequence = tokenizer.texts_to_sequences([lyrics])
|
56 |
-
padded_sequence = pad_sequences(sequence, maxlen=50) # Adjust the maxlen to match the expected input size
|
57 |
-
emotion = emotion_model.predict(padded_sequence).flatten()
|
58 |
-
|
59 |
# Combine emotion and audio features for recommendation
|
60 |
-
combined_features = np.concatenate([emotion, audio_features_scaled_knn[song_index_to_recommend]])
|
61 |
-
|
62 |
-
# Display the predicted emotion and recommendations
|
63 |
-
st.write(f"Predicted Emotion: {emotion}")
|
64 |
|
65 |
if not knn_recs.empty:
|
66 |
st.write("KNN Recommendations:")
|
|
|
7 |
from sklearn.neighbors import NearestNeighbors
|
8 |
from sklearn.preprocessing import StandardScaler
|
9 |
|
|
|
|
|
|
|
10 |
# Load the KNN model
|
11 |
knn_model = joblib.load('knn_model.joblib')
|
12 |
|
|
|
|
|
|
|
13 |
# Load the dataset
|
14 |
df = pd.read_csv('df1.csv')
|
15 |
|
|
|
42 |
# Get song index from user input
|
43 |
song_index_to_recommend = st.number_input('Enter song index:', min_value=0, max_value=len(df)-1, value=0)
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
# Combine emotion and audio features for recommendation
|
46 |
+
#combined_features = np.concatenate([emotion, audio_features_scaled_knn[song_index_to_recommend]])
|
|
|
|
|
|
|
47 |
|
48 |
if not knn_recs.empty:
|
49 |
st.write("KNN Recommendations:")
|