Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -151,43 +151,47 @@ def main():
|
|
151 |
user_input = st.text_area("Enter a short sentence about your current mood:", "")
|
152 |
|
153 |
if user_input:
|
154 |
-
#
|
155 |
-
|
156 |
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
st.write(f"Raw Model Result: {result}") # Debug output to see raw result
|
161 |
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
|
|
|
|
|
|
|
|
|
|
171 |
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
|
189 |
-
|
190 |
-
|
191 |
|
192 |
# Run the Streamlit app
|
193 |
if __name__ == "__main__":
|
|
|
151 |
user_input = st.text_area("Enter a short sentence about your current mood:", "")
|
152 |
|
153 |
if user_input:
|
154 |
+
# Display Enter button only after user has entered input
|
155 |
+
enter_button = st.button("Enter")
|
156 |
|
157 |
+
if enter_button:
|
158 |
+
# Clean the input text (stripping unnecessary spaces, lowercasing)
|
159 |
+
clean_input = user_input.strip().lower()
|
|
|
160 |
|
161 |
+
# Use the model to predict emotion
|
162 |
+
try:
|
163 |
+
result = emotion_classifier(clean_input)
|
164 |
+
st.write(f"Raw Model Result: {result}") # Debug output to see raw result
|
165 |
+
|
166 |
+
emotion = result[0]['label'].lower()
|
167 |
+
|
168 |
+
st.subheader(f"Emotion Detected: {emotion.capitalize()}")
|
169 |
+
|
170 |
+
# Get well-being suggestions based on emotion
|
171 |
+
suggestions = get_well_being_suggestions(emotion)
|
172 |
+
|
173 |
+
# Display text suggestions
|
174 |
+
st.write(suggestions["text"])
|
175 |
|
176 |
+
# Display links
|
177 |
+
if suggestions["links"]:
|
178 |
+
st.write("Useful Resources:")
|
179 |
+
for link in suggestions["links"]:
|
180 |
+
st.markdown(f"[{link}]({link})", unsafe_allow_html=True)
|
181 |
|
182 |
+
# Display video links
|
183 |
+
if suggestions["videos"]:
|
184 |
+
st.write("Relaxation Videos:")
|
185 |
+
for video in suggestions["videos"]:
|
186 |
+
st.markdown(f"[Watch here]({video})", unsafe_allow_html=True)
|
187 |
|
188 |
+
# Add a button for a summary
|
189 |
+
if st.button('Summary'):
|
190 |
+
st.write(f"Emotion detected: {emotion.capitalize()}. Here are your well-being suggestions to enhance your mood.")
|
191 |
+
st.write("Explore the links and videos to improve your emotional health!")
|
192 |
|
193 |
+
except Exception as e:
|
194 |
+
st.error(f"Error predicting emotion: {str(e)}")
|
195 |
|
196 |
# Run the Streamlit app
|
197 |
if __name__ == "__main__":
|