File size: 2,459 Bytes
408fb7d
 
 
e191646
408fb7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e191646
729a8ba
 
e191646
729a8ba
408fb7d
729a8ba
408fb7d
 
 
 
e191646
408fb7d
 
 
 
 
 
 
729a8ba
408fb7d
729a8ba
408fb7d
 
 
 
e191646
408fb7d
 
 
729a8ba
408fb7d
e191646
408fb7d
 
 
 
 
 
 
 
 
e191646
408fb7d
 
 
 
e191646
408fb7d
 
 
 
 
 
e191646
408fb7d
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import streamlit as st
import numpy as np


st.markdown(
    """
    <style>
        .header-text {
            color: #333333;
            text-align: center;
            font-size: 24px;
            font-weight: bold;
            margin-bottom: 20px;
        }
        .result-text {
            color: #333333;
            font-size: 18px;
            margin-bottom: 10px;
        }
    </style>
    """,
    unsafe_allow_html=True
)

def map_to_emotion(spo2, bp, temp):

    spo2_numeric = float(spo2.split('%')[0])


    if spo2_numeric >= 96:
        spo2_emotion = ["Joy", "Anticipation", "Trust"]
    elif spo2_numeric == 93 or spo2_numeric == 94:
        spo2_emotion = ["Fear"]
    else:
        spo2_emotion = ["Anger", "Disgust"]


    if bp == "110/70mmHg":
        bp_emotion = ["Trust"]
    elif bp == "122/74 mmHg":
        bp_emotion = ["Joy"]
    else:
        bp_emotion = ["Surprise"]

    if temp >= "98.7F" and temp <= "99.1F":
        temp_emotion = ["Joy", "Surprise", "Disgust", "Anticipation"]
    elif temp < "98.7F":
        temp_emotion = ["Sadness"]
    else:
        temp_emotion = ["Fear", "Anger"]


    emotions = spo2_emotion + bp_emotion + temp_emotion
    return emotions


def predict_levels(emotions):
    
    stress_percentage = np.random.randint(0, 100)
    anxiety_percentage = np.random.randint(0, 100)
    depression_percentage = np.random.randint(0, 100)
    return stress_percentage, anxiety_percentage, depression_percentage

def main():
    st.title("Emotion Analysis and Mental Health Prediction")
    st.markdown("### Enter Vital Parameters:")
    
    
    spo2 = st.selectbox("Select Spo2 Level", ["96% or more", "93-94%", "92% or less"])
    bp = st.selectbox("Select Blood Pressure Level", ["110/70mmHg", "122/74 mmHg", "Others"])
    temp = st.selectbox("Select Body Temperature", ["98.7F-99.1F", "Less than 98.7F", "Greater than 99.1F"])

    
    emotions = map_to_emotion(spo2, bp, temp)

    st.markdown("### Emotion Analysis Results:")
    for emotion in emotions:
        st.write(f"- {emotion}")

    
    st.markdown("### Predicted Mental Health Levels:")
    stress_percentage, anxiety_percentage, depression_percentage = predict_levels(emotions)
    st.write(f"Stress Percentage (approx): {stress_percentage}%")
    st.write(f"Anxiety Percentage (approx): {anxiety_percentage}%")
    st.write(f"Depression Percentage (approx): {depression_percentage}%")

if __name__ == "__main__":
    main()