File size: 3,931 Bytes
bb770b6
 
 
5713ae0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bb770b6
5713ae0
 
 
 
 
bb770b6
5713ae0
 
 
bb770b6
 
 
 
5713ae0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bb770b6
5713ae0
 
 
 
 
 
 
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import streamlit as st
from transformers import pipeline

# Load the emotion analysis pipeline using an open-access model
emotion_analyzer = pipeline(
    "text-classification", 
    model="j-hartmann/emotion-english-distilroberta-base"
)

# App title and description
st.set_page_config(page_title="Hawaii Emotion Wellness", layout="centered", page_icon="🌴")
st.markdown(
    """
    <style>
        body {
            background-color: #E0F7FA;
            color: #004D40;
        }
        .main-header {
            font-size: 36px;
            font-weight: bold;
            text-align: center;
            margin-bottom: 10px;
        }
        .sub-header {
            font-size: 18px;
            text-align: center;
            margin-bottom: 20px;
        }
        .suggestion-card {
            background-color: #B2EBF2;
            padding: 15px;
            border-radius: 8px;
            margin-bottom: 15px;
        }
    </style>
    """,
    unsafe_allow_html=True,
)

st.markdown('<div class="main-header">🌺 Hawaii Emotion Wellness App 🌴</div>', unsafe_allow_html=True)
st.markdown('<div class="sub-header">Understand your emotions and find the right balance in paradise.</div>', unsafe_allow_html=True)

# Step 1: Collect user's responses
st.markdown("### Answer these three questions to get started:")
questions = [
    "How are you feeling right now? (e.g., stressed, happy, sad)",
    "What is the most pressing issue on your mind currently?",
    "On a scale of 1-10, how motivated do you feel to take care of yourself today?",
]

responses = []
for question in questions:
    response = st.text_input(question)
    responses.append(response)

# Analyze the emotions if the user has answered all questions
if st.button("Analyze Emotions"):
    if all(responses):
        # Aggregate responses into a single input for emotion analysis
        aggregated_response = " ".join(responses)
        emotion_results = emotion_analyzer(aggregated_response)

        # Get the most likely emotion
        predicted_emotion = emotion_results[0]["label"]
        st.markdown(f"### Your Predicted Emotion: **{predicted_emotion}** 🎭")

        # Provide well-being suggestions
        st.markdown("### Here's what we recommend for you:")
        suggestions = {
            "joy": [
                {"activity": "Go for a walk on the beach", "url": "https://www.hawaiibeachwalks.com"},
                {"activity": "Try a short surfing session", "url": "https://www.learnsurf.com"},
                {"activity": "Join a hula dancing class", "url": "https://www.hulahawaii.com"},
            ],
            "sadness": [
                {"activity": "Practice deep breathing for 5 minutes", "url": "https://www.breathingexercise.com"},
                {"activity": "Watch a calming ocean video", "url": "https://www.youtube.com/watch?v=lM02vNMRRB0"},
                {"activity": "Do a quick yoga session", "url": "https://www.doyogawithme.com"},
            ],
            # Add more emotions as needed
        }

        user_suggestions = suggestions.get(predicted_emotion.lower(), [])
        if user_suggestions:
            for suggestion in user_suggestions:
                st.markdown(
                    f"""
                    <div class="suggestion-card">
                        <strong>{suggestion['activity']}</strong>
                        <br>
                        <a href="{suggestion['url']}" target="_blank">Learn More</a>
                    </div>
                    """,
                    unsafe_allow_html=True,
                )
        else:
            st.markdown("Stay positive! Enjoy the aloha spirit and take a deep breath.")
    else:
        st.warning("Please answer all the questions to analyze your emotions.")

# Footer
st.markdown("---")
st.markdown(
    "Built with ❤️ for the Hawaii Hackathon 2024 by [Your Team Name]. Deployed on Hugging Face Spaces."
)