You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🧠 Emotion intelligence meets clinical data — production-ready NLP sentiment analysis pipeline powered by DistilRoBERTa + structured medical report extraction via Pytesseract OCR + intelligent cross-referencing against a curated medical conditions database — served through a blazing-fast Flask REST API.
Analyze free-text for emotional state using transformer-based NLP classification
Field
Value
Method
URL
http://localhost:5000/api/chat
Content-Type
application/json
Returns
Dominant emotion · confidence · risk level · AI advice
curl -X POST http://localhost:5000/api/chat \
-H "Content-Type: application/json" \
-d '{"message":"I have been feeling really anxious and overwhelmed lately."}'
📤 Sample Response · 200 OK
{
"status": "success",
"emotion_analysis": {
"dominant_emotion": "fear",
"confidence": 78.4,
"risk_level": "high",
"color": "red",
"advice": "Fear and anxiety are linked. Grounding techniques and professional support are recommended.",
"all_emotions": [
{ "label": "fear", "score": 78.4 },
{ "label": "sadness", "score": 12.1 },
{ "label": "neutral", "score": 5.3 },
{ "label": "anger", "score": 2.8 }
]
}
}
Response Schema
Field
Type
Description
dominant_emotion
string
Highest-confidence predicted emotion label
confidence
float
Probability score 0–100 for dominant class
risk_level
string
low · low-medium · medium · high
color
string
UI color token mapped to emotion
advice
string
Personalised AI-generated mental health guidance
all_emotions
array
Full softmax probability distribution (sorted)
Missing or empty message field
📄 Medical Report Scanner — OCR Operations
Upload a medical report image — extracts vitals, lab values, medications and diagnoses via computer vision OCR
Full-stack intelligence — emotion NLP + OCR extraction + medical cross-reference correlation in one call
Field
Value
Method
URL
http://localhost:5000/api/analyze
Content-Type
multipart/form-data
Returns
Emotion analysis + OCR result + cross-reference matches
curl -X POST http://localhost:5000/api/analyze \
-F "message=I feel exhausted and completely hopeless" \
-F "file=@/path/to/medical_report.png"
📤 Sample Response · 200 OK
{
"status": "success",
"emotion_analysis": {
"dominant_emotion": "sadness",
"confidence": 84.2,
"risk_level": "medium",
"color": "blue",
"advice": "Feelings of sadness are valid. Consider reaching out to a friend or therapist."
},
"ocr_result": {
"diagnoses": ["Impression: Major Depressive Disorder"],
"medications": ["Sertraline 50mg daily"]
},
"cross_reference": {
"condition_matches": [
{
"condition": "depression",
"matched_symptoms": ["hopelessness", "fatigue", "low energy"],
"known_medications": ["Sertraline", "Fluoxetine", "Bupropion"],
"recommendation": "Consult a psychiatrist for a full clinical evaluation."
}
],
"emotion_health_correlation": "⚠️ Your emotional state aligns with detected medical indicators. Professional consultation is strongly advised.",
"total_matches": 1
}
}
Cross-Reference Logic
Trigger Condition
Output
emotion = sadness or fear + depression/anxiety in report
⚠️ Strong clinical correlation warning
risk_level = high
🔴 Immediate professional referral message
Medical keyword matches found
📋 Recommendations surfaced from DB
No matches + low risk
✅ Continue monitoring your wellbeing
Neither message nor file provided
⚙️ System — Health & Monitoring
Service liveness probe — integrate with Docker HEALTHCHECK, Prometheus, or UptimeRobot for production monitoring
Field
Value
Method
URL
http://localhost:5000/api/health
Content-Type
application/json
Returns
Service status confirmation
curl -X GET http://localhost:5000/api/health
📤 Sample Response · 200 OK
{
"status": "ok",
"service": "Mental Health AI API"
}
💡 Use this endpoint in DockerHEALTHCHECK, GitHub Actions smoke tests, or UptimeRobot ping monitors to verify API availability in CI/CD and production deployments.
This project is built for educational, research, and portfolio demonstration purposes only.
It is not a certified medical device and must not be used as a substitute for professional psychological or clinical advice, diagnosis, or treatment.
If you or someone you know is experiencing a mental health crisis, please contact a qualified healthcare professional or a crisis helpline immediately.
🤝 Contributing
git checkout -b feature/your-feature-name
git commit -m "feat: describe your change clearly"
git push origin feature/your-feature-name
# Open a Pull Request on GitHub ↗