Srinivas T B
commited on
app
Browse files
app.py
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import numpy as np
|
3 |
+
|
4 |
+
# Custom CSS for styling
|
5 |
+
st.markdown(
|
6 |
+
"""
|
7 |
+
<style>
|
8 |
+
.header-text {
|
9 |
+
color: #333333;
|
10 |
+
text-align: center;
|
11 |
+
font-size: 24px;
|
12 |
+
font-weight: bold;
|
13 |
+
margin-bottom: 20px;
|
14 |
+
}
|
15 |
+
.result-text {
|
16 |
+
color: #333333;
|
17 |
+
font-size: 18px;
|
18 |
+
margin-bottom: 10px;
|
19 |
+
}
|
20 |
+
</style>
|
21 |
+
""",
|
22 |
+
unsafe_allow_html=True
|
23 |
+
)
|
24 |
+
|
25 |
+
def map_to_emotion(spo2, bp, temp):
|
26 |
+
# Spo2 mapping
|
27 |
+
if spo2 >= 96:
|
28 |
+
spo2_emotion = ["Joy", "Anticipation", "Trust"]
|
29 |
+
elif spo2 == 93 or spo2 == 94:
|
30 |
+
spo2_emotion = ["Fear"]
|
31 |
+
else:
|
32 |
+
spo2_emotion = ["Anger", "Disgust"]
|
33 |
+
|
34 |
+
# BP mapping
|
35 |
+
if bp == "110/70mmHg":
|
36 |
+
bp_emotion = ["Trust"]
|
37 |
+
elif bp == "122/74 mmHg":
|
38 |
+
bp_emotion = ["Joy"]
|
39 |
+
else:
|
40 |
+
bp_emotion = ["Surprise"]
|
41 |
+
|
42 |
+
# Temperature mapping
|
43 |
+
if temp >= 98.7 and temp <= 99.1:
|
44 |
+
temp_emotion = ["Joy", "Surprise", "Disgust", "Anticipation"]
|
45 |
+
elif temp < 98.7:
|
46 |
+
temp_emotion = ["Sadness"]
|
47 |
+
else:
|
48 |
+
temp_emotion = ["Fear", "Anger"]
|
49 |
+
|
50 |
+
# Combine all emotions
|
51 |
+
emotions = spo2_emotion + bp_emotion + temp_emotion
|
52 |
+
return emotions
|
53 |
+
|
54 |
+
def predict_levels(emotions):
|
55 |
+
# Placeholder for machine learning models
|
56 |
+
# Here, we generate random predictions as placeholders
|
57 |
+
stress_percentage = np.random.randint(0, 100)
|
58 |
+
anxiety_percentage = np.random.randint(0, 100)
|
59 |
+
depression_percentage = np.random.randint(0, 100)
|
60 |
+
return stress_percentage, anxiety_percentage, depression_percentage
|
61 |
+
|
62 |
+
def main():
|
63 |
+
st.title("Emotion Analysis and Mental Health Prediction")
|
64 |
+
st.markdown("### Enter Vital Parameters:")
|
65 |
+
|
66 |
+
# User inputs
|
67 |
+
spo2 = st.selectbox("Select Spo2 Level", ["96% or more", "93-94%", "92% or less"])
|
68 |
+
bp = st.selectbox("Select Blood Pressure Level", ["110/70mmHg", "122/74 mmHg", "Others"])
|
69 |
+
temp = st.selectbox("Select Body Temperature", ["98.7F-99.1F", "Less than 98.7F", "Greater than 99.1F"])
|
70 |
+
|
71 |
+
# Map inputs to emotions
|
72 |
+
emotions = map_to_emotion(spo2, bp, temp)
|
73 |
+
|
74 |
+
st.markdown("### Emotion Analysis Results:")
|
75 |
+
for emotion in emotions:
|
76 |
+
st.write(f"- {emotion}")
|
77 |
+
|
78 |
+
# Predict levels using machine learning models
|
79 |
+
st.markdown("### Predicted Mental Health Levels:")
|
80 |
+
stress_percentage, anxiety_percentage, depression_percentage = predict_levels(emotions)
|
81 |
+
st.write(f"Stress Percentage (approx): {stress_percentage}%")
|
82 |
+
st.write(f"Anxiety Percentage (approx): {anxiety_percentage}%")
|
83 |
+
st.write(f"Depression Percentage (approx): {depression_percentage}%")
|
84 |
+
|
85 |
+
if __name__ == "__main__":
|
86 |
+
main()
|