Srinivas T B
commited on
bug fixess
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
import numpy as np
|
3 |
|
4 |
-
|
5 |
st.markdown(
|
6 |
"""
|
7 |
<style>
|
@@ -23,10 +23,10 @@ st.markdown(
|
|
23 |
)
|
24 |
|
25 |
def map_to_emotion(spo2, bp, temp):
|
26 |
-
|
27 |
spo2_numeric = float(spo2.split('%')[0])
|
28 |
|
29 |
-
|
30 |
if spo2_numeric >= 96:
|
31 |
spo2_emotion = ["Joy", "Anticipation", "Trust"]
|
32 |
elif spo2_numeric == 93 or spo2_numeric == 94:
|
@@ -34,7 +34,7 @@ def map_to_emotion(spo2, bp, temp):
|
|
34 |
else:
|
35 |
spo2_emotion = ["Anger", "Disgust"]
|
36 |
|
37 |
-
|
38 |
if bp == "110/70mmHg":
|
39 |
bp_emotion = ["Trust"]
|
40 |
elif bp == "122/74 mmHg":
|
@@ -42,7 +42,6 @@ def map_to_emotion(spo2, bp, temp):
|
|
42 |
else:
|
43 |
bp_emotion = ["Surprise"]
|
44 |
|
45 |
-
# Temperature mapping
|
46 |
if temp >= "98.7F" and temp <= "99.1F":
|
47 |
temp_emotion = ["Joy", "Surprise", "Disgust", "Anticipation"]
|
48 |
elif temp < "98.7F":
|
@@ -50,14 +49,13 @@ def map_to_emotion(spo2, bp, temp):
|
|
50 |
else:
|
51 |
temp_emotion = ["Fear", "Anger"]
|
52 |
|
53 |
-
|
54 |
emotions = spo2_emotion + bp_emotion + temp_emotion
|
55 |
return emotions
|
56 |
|
57 |
|
58 |
def predict_levels(emotions):
|
59 |
-
|
60 |
-
# Here, we generate random predictions as placeholders
|
61 |
stress_percentage = np.random.randint(0, 100)
|
62 |
anxiety_percentage = np.random.randint(0, 100)
|
63 |
depression_percentage = np.random.randint(0, 100)
|
@@ -67,19 +65,19 @@ def main():
|
|
67 |
st.title("Emotion Analysis and Mental Health Prediction")
|
68 |
st.markdown("### Enter Vital Parameters:")
|
69 |
|
70 |
-
|
71 |
spo2 = st.selectbox("Select Spo2 Level", ["96% or more", "93-94%", "92% or less"])
|
72 |
bp = st.selectbox("Select Blood Pressure Level", ["110/70mmHg", "122/74 mmHg", "Others"])
|
73 |
temp = st.selectbox("Select Body Temperature", ["98.7F-99.1F", "Less than 98.7F", "Greater than 99.1F"])
|
74 |
|
75 |
-
|
76 |
emotions = map_to_emotion(spo2, bp, temp)
|
77 |
|
78 |
st.markdown("### Emotion Analysis Results:")
|
79 |
for emotion in emotions:
|
80 |
st.write(f"- {emotion}")
|
81 |
|
82 |
-
|
83 |
st.markdown("### Predicted Mental Health Levels:")
|
84 |
stress_percentage, anxiety_percentage, depression_percentage = predict_levels(emotions)
|
85 |
st.write(f"Stress Percentage (approx): {stress_percentage}%")
|
|
|
1 |
import streamlit as st
|
2 |
import numpy as np
|
3 |
|
4 |
+
|
5 |
st.markdown(
|
6 |
"""
|
7 |
<style>
|
|
|
23 |
)
|
24 |
|
25 |
def map_to_emotion(spo2, bp, temp):
|
26 |
+
|
27 |
spo2_numeric = float(spo2.split('%')[0])
|
28 |
|
29 |
+
|
30 |
if spo2_numeric >= 96:
|
31 |
spo2_emotion = ["Joy", "Anticipation", "Trust"]
|
32 |
elif spo2_numeric == 93 or spo2_numeric == 94:
|
|
|
34 |
else:
|
35 |
spo2_emotion = ["Anger", "Disgust"]
|
36 |
|
37 |
+
|
38 |
if bp == "110/70mmHg":
|
39 |
bp_emotion = ["Trust"]
|
40 |
elif bp == "122/74 mmHg":
|
|
|
42 |
else:
|
43 |
bp_emotion = ["Surprise"]
|
44 |
|
|
|
45 |
if temp >= "98.7F" and temp <= "99.1F":
|
46 |
temp_emotion = ["Joy", "Surprise", "Disgust", "Anticipation"]
|
47 |
elif temp < "98.7F":
|
|
|
49 |
else:
|
50 |
temp_emotion = ["Fear", "Anger"]
|
51 |
|
52 |
+
|
53 |
emotions = spo2_emotion + bp_emotion + temp_emotion
|
54 |
return emotions
|
55 |
|
56 |
|
57 |
def predict_levels(emotions):
|
58 |
+
|
|
|
59 |
stress_percentage = np.random.randint(0, 100)
|
60 |
anxiety_percentage = np.random.randint(0, 100)
|
61 |
depression_percentage = np.random.randint(0, 100)
|
|
|
65 |
st.title("Emotion Analysis and Mental Health Prediction")
|
66 |
st.markdown("### Enter Vital Parameters:")
|
67 |
|
68 |
+
|
69 |
spo2 = st.selectbox("Select Spo2 Level", ["96% or more", "93-94%", "92% or less"])
|
70 |
bp = st.selectbox("Select Blood Pressure Level", ["110/70mmHg", "122/74 mmHg", "Others"])
|
71 |
temp = st.selectbox("Select Body Temperature", ["98.7F-99.1F", "Less than 98.7F", "Greater than 99.1F"])
|
72 |
|
73 |
+
|
74 |
emotions = map_to_emotion(spo2, bp, temp)
|
75 |
|
76 |
st.markdown("### Emotion Analysis Results:")
|
77 |
for emotion in emotions:
|
78 |
st.write(f"- {emotion}")
|
79 |
|
80 |
+
|
81 |
st.markdown("### Predicted Mental Health Levels:")
|
82 |
stress_percentage, anxiety_percentage, depression_percentage = predict_levels(emotions)
|
83 |
st.write(f"Stress Percentage (approx): {stress_percentage}%")
|