sad-app / app.py
Srinivas T B
bug fixess
e191646 verified
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()