tarrasyed19472007 commited on
Commit
112c544
·
verified ·
1 Parent(s): a5d4660

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
- # Attempt to load the model
5
  @st.cache_resource
6
  def load_model():
7
  try:
@@ -101,9 +101,12 @@ def main():
101
  user_input = st.text_area("Enter a short sentence about your current mood:", "")
102
 
103
  if user_input:
 
 
 
104
  # Use the model to predict emotion
105
  try:
106
- result = emotion_classifier(user_input)
107
  emotion = result[0]['label'].lower()
108
 
109
  st.subheader(f"Emotion Detected: {emotion.capitalize()}")
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
+ # Load emotion classification model
5
  @st.cache_resource
6
  def load_model():
7
  try:
 
101
  user_input = st.text_area("Enter a short sentence about your current mood:", "")
102
 
103
  if user_input:
104
+ # Clean the input text (stripping unnecessary spaces, lowercasing)
105
+ clean_input = user_input.strip().lower()
106
+
107
  # Use the model to predict emotion
108
  try:
109
+ result = emotion_classifier(clean_input)
110
  emotion = result[0]['label'].lower()
111
 
112
  st.subheader(f"Emotion Detected: {emotion.capitalize()}")