Skip to content

Commit

Permalink
docker path changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tharoosha committed Oct 28, 2023
1 parent 1c416ec commit fd838ac
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
6 changes: 4 additions & 2 deletions backend/ml_models/emotion_detection/emotionScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,12 @@ def initialize():
''' Load the model and tokenizer from the saved files '''


with open('../backend/ml_models/emotion_detection/tokenizer.pkl', 'rb') as f:
with open('/usr/src/app/ml_models/emotion_detection/tokenizer.pkl', 'rb') as f:
# with open('../backend/ml_models/emotion_detection/tokenizer.pkl', 'rb') as f:
tokenizer = pickle.load(f)

model = tf.keras.models.load_model('../backend/ml_models/emotion_detection/emotion_model')
model = tf.keras.models.load_model('/usr/src/app/ml_models/emotion_detection/emotion_model')
# model = tf.keras.models.load_model('../backend/ml_models/emotion_detection/emotion_model')

#################################################################################################################################################################################

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
def script_run(input_mood):
try:

file_path = '../backend/ml_models/spotify_recommendation/tokenizer.pkl'
file_path = '/usr/src/app/ml_models/spotify_recommendation/tokenizer.pkl'
# file_path = '../backend/ml_models/spotify_recommendation/tokenizer.pkl'
if os.path.exists(file_path):
with open('../backend/ml_models/spotify_recommendation/tokenizer.pkl', 'rb') as f:
with open('/usr/src/app/ml_models/spotify_recommendation/tokenizer.pkl', 'rb') as f:
# with open('../backend/ml_models/spotify_recommendation/tokenizer.pkl', 'rb') as f:
scaler = pickle.load(f)

model = tf.keras.models.load_model('../backend/ml_models/spotify_recommendation/spotify_model')
model = tf.keras.models.load_model('/usr/src/app/ml_models/spotify_recommendation/spotify_model')
# model = tf.keras.models.load_model('../backend/ml_models/spotify_recommendation/spotify_model')

result = spotifyRecommendScript.getRecommendation(input_mood, model, scaler)
# result = json.dumps(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def initialize():
#######################################################################################################################################
'''Train model from scratch and save it along with the scaler'''

df=pd.read_csv("backend/ml_models/spotify_recommendation/dataset.csv")
df=pd.read_csv("/usr/src/app/ml_models/spotify_recommendation/dataset.csv")
# df=pd.read_csv("backend/ml_models/spotify_recommendation/dataset.csv")


df['Mood'] = df['Mood'].apply(class_to_index)

Expand Down Expand Up @@ -127,10 +129,12 @@ def initialize():
print(f"Test loss: {loss:.4f}, Test accuracy: {accuracy:.4f}")

# Save the tokenizer
with open('backend/ml_models/spotify_recommendation/tokenizer.pkl', 'wb') as f:
with open('/usr/src/app/ml_models/spotify_recommendation/tokenizer.pkl', 'wb') as f:
# with open('backend/ml_models/spotify_recommendation/tokenizer.pkl', 'wb') as f:
pickle.dump(scaler, f)

model.save('backend/ml_models/spotify_recommendation/spotify_model')
model.save('/usr/src/app/ml_models/spotify_recommendation/spotify_model')
# model.save('backend/ml_models/spotify_recommendation/spotify_model')

#######################################################################################################################################

Expand Down

0 comments on commit fd838ac

Please sign in to comment.