Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +36 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
st.set_page_config(page_title="Mental Wellness Diary Analyzer", page_icon="🧠")
|
5 |
+
st.title("🧠 Mental Wellness Diary Analyzer")
|
6 |
+
|
7 |
+
# Load a lightweight language model
|
8 |
+
generator = pipeline("text-generation", model="distilgpt2", max_new_tokens=200)
|
9 |
+
|
10 |
+
def analyze_journal(entry):
|
11 |
+
prompt = f"""
|
12 |
+
Analyze the following journal entry:
|
13 |
+
"{entry}"
|
14 |
+
|
15 |
+
Determine the following:
|
16 |
+
1. Emotional tone of the journal.
|
17 |
+
2. Any recurring themes or sentiments.
|
18 |
+
3. Personalized motivational advice.
|
19 |
+
|
20 |
+
Be friendly and encouraging in your tone.
|
21 |
+
"""
|
22 |
+
output = generator(prompt)[0]["generated_text"]
|
23 |
+
return output.split("Determine the following:")[-1].strip()
|
24 |
+
|
25 |
+
# User input
|
26 |
+
journal_entry = st.text_area("✍️ Write your journal entry here:")
|
27 |
+
|
28 |
+
if st.button("🧠 Analyze"):
|
29 |
+
if journal_entry.strip():
|
30 |
+
st.info("Analyzing your entry with AI...")
|
31 |
+
result = analyze_journal(journal_entry)
|
32 |
+
st.markdown("### 💬 Analysis Result")
|
33 |
+
st.write(result)
|
34 |
+
else:
|
35 |
+
st.warning("Please enter your journal entry first.")
|
36 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
transformers
|
3 |
+
torch
|