SidraTul commited on
Commit
2479207
Β·
verified Β·
1 Parent(s): 6219c10

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -27
app.py CHANGED
@@ -43,45 +43,44 @@
43
 
44
 
45
  import streamlit as st
 
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  st.title("🧠 Mental Health Assistant Bot")
48
 
49
- # User Input
50
  user_input = st.text_input("How are you feeling today?", "")
51
 
52
  if st.button("Submit"):
53
  if user_input:
54
- # Get Emotion Analysis
55
  emotion_result = emotion_pipeline(user_input)[0]
56
  st.write(f"**Emotion Detected:** {emotion_result['label']} ({emotion_result['score']:.2f})")
57
 
58
- # Get Mental Health Condition Analysis
59
- mental_health_result = mental_bert_pipeline(user_input)[0]
60
- st.write(f"**Possible Mental Health Condition:** {mental_health_result['label']} ({mental_health_result['score']:.2f})")
61
-
62
- # Get Stress Level Analysis
63
  stress_result = stress_pipeline(user_input)[0]
64
  st.write(f"**Stress Level:** {stress_result['label']} ({stress_result['score']:.2f})")
65
 
66
- # Chatbot Response using DeepSeek AI
 
 
 
 
67
  deepseek_response = deepseek_pipeline(user_input, max_length=100, do_sample=True)[0]['generated_text']
68
  st.write(f"πŸ€– **Chatbot:** {deepseek_response}")
69
-
70
- # Question Answering Section
71
- st.subheader("Ask Mental Health Questions")
72
- user_question = st.text_input("Ask me anything about mental health:", "")
73
-
74
- if st.button("Ask"):
75
- if user_question:
76
- answer = qa_pipeline(question=user_question, context="Mental health is important for overall well-being.")
77
- st.write(f"**Answer:** {answer['answer']}")
78
-
79
- # PHQ-9 Depression Assessment
80
- st.subheader("Depression Severity Assessment (PHQ-9)")
81
- phq9_question = st.text_input("Describe your mood over the last two weeks:", "")
82
-
83
- if st.button("Analyze Depression Level"):
84
- if phq9_question:
85
- phq9_result = phq9_pipeline(phq9_question)[0]
86
- st.write(f"**PHQ-9 Score Suggests:** {phq9_result['label']} ({phq9_result['score']:.2f})")
87
-
 
43
 
44
 
45
  import streamlit as st
46
+ from transformers import pipeline, AutoTokenizer
47
 
48
+ # βœ… Load Emotion Recognition Model
49
+ emotion_pipeline = pipeline("text-classification", model="distilbert-base-uncased-finetuned-emotion")
50
+
51
+ # βœ… Load Stress Detection Model
52
+ stress_pipeline = pipeline("text-classification", model="mental-health-roberta")
53
+
54
+ # βœ… Load Mental Disorder Detection Model
55
+ mental_bert_pipeline = pipeline("text-classification", model="mental-bert")
56
+
57
+ # βœ… Load PHQ-9 Depression Severity Classifier
58
+ phq9_pipeline = pipeline("text-classification", model="PHQ-9 Depression Classifier")
59
+
60
+ # βœ… Load Chatbot Model (DeepSeek)
61
+ deepseek_model = "deepseek-ai/deepseek-llm-7b"
62
+ deepseek_tokenizer = AutoTokenizer.from_pretrained(deepseek_model)
63
+ deepseek_pipeline = pipeline("text-generation", model=deepseek_model, tokenizer=deepseek_tokenizer)
64
+
65
+ # πŸ₯ Streamlit UI
66
  st.title("🧠 Mental Health Assistant Bot")
67
 
 
68
  user_input = st.text_input("How are you feeling today?", "")
69
 
70
  if st.button("Submit"):
71
  if user_input:
72
+ # βœ… Emotion Analysis
73
  emotion_result = emotion_pipeline(user_input)[0]
74
  st.write(f"**Emotion Detected:** {emotion_result['label']} ({emotion_result['score']:.2f})")
75
 
76
+ # βœ… Stress Level Analysis
 
 
 
 
77
  stress_result = stress_pipeline(user_input)[0]
78
  st.write(f"**Stress Level:** {stress_result['label']} ({stress_result['score']:.2f})")
79
 
80
+ # βœ… Mental Health Condition Detection
81
+ mental_health_result = mental_bert_pipeline(user_input)[0]
82
+ st.write(f"**Possible Mental Health Condition:** {mental_health_result['label']} ({mental_health_result['score']:.2f})")
83
+
84
+ # βœ… AI Chatbot Response
85
  deepseek_response = deepseek_pipeline(user_input, max_length=100, do_sample=True)[0]['generated_text']
86
  st.write(f"πŸ€– **Chatbot:** {deepseek_response}")