Spaces:
Sleeping
Sleeping
Commit ·
0c46c35
0
Parent(s):
Initial clean commit with LFS models
Browse files- .gitattributes +6 -0
- .gitignore +60 -0
- Dockerfile +25 -0
- app/__init__.py +0 -0
- app/api/endpoints/facial.py +35 -0
- app/api/endpoints/remedies.py +22 -0
- app/api/endpoints/therapist.py +33 -0
- app/main.py +33 -0
- app/ml_assets/MEDICATION.csv +47 -0
- app/ml_assets/emotion_model_trained.h5 +3 -0
- app/ml_assets/emotion_model_trained.keras +3 -0
- app/ml_assets/haarcascade_frontalface_default.xml +0 -0
- app/services/emotion_engine.py +91 -0
- app/services/llm_engine.py +79 -0
- app/services/remedy_engine.py +54 -0
- download_models.py +25 -0
- requirements.txt +17 -0
.gitattributes
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.keras filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
app/ml_assets/emotion_model_trained.h5 filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
app/ml_assets/emotion_model_trained.keras filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
app/ml_assets/*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
app/ml_assets/*.keras filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ========================
|
| 2 |
+
# 🐍 PYTHON / BACKEND
|
| 3 |
+
# ========================
|
| 4 |
+
__pycache__/
|
| 5 |
+
*.py[cod]
|
| 6 |
+
*$py.class
|
| 7 |
+
venv/
|
| 8 |
+
.venv/
|
| 9 |
+
env/
|
| 10 |
+
.env
|
| 11 |
+
instance/
|
| 12 |
+
.pytest_cache/
|
| 13 |
+
backend/.env
|
| 14 |
+
|
| 15 |
+
# ========================
|
| 16 |
+
# ⚛️ NODE / FRONTEND
|
| 17 |
+
# ========================
|
| 18 |
+
node_modules/
|
| 19 |
+
/frontend/dist/
|
| 20 |
+
/frontend/build/
|
| 21 |
+
/frontend/.env
|
| 22 |
+
/frontend/.env.local
|
| 23 |
+
npm-debug.log*
|
| 24 |
+
yarn-debug.log*
|
| 25 |
+
yarn-error.log*
|
| 26 |
+
.eslintcache
|
| 27 |
+
|
| 28 |
+
# ========================
|
| 29 |
+
# 📓 JUPYTER NOTEBOOKS
|
| 30 |
+
# ========================
|
| 31 |
+
.ipynb_checkpoints/
|
| 32 |
+
*/.ipynb_checkpoints/
|
| 33 |
+
|
| 34 |
+
# ========================
|
| 35 |
+
# 💾 DATASETS & LARGE FILES
|
| 36 |
+
# ========================
|
| 37 |
+
# Ignore raw datasets (Standard practice: download them separately)
|
| 38 |
+
datasets/
|
| 39 |
+
/backend/app/ml_assets
|
| 40 |
+
/backend/app/ml_assets/MEDICATION.csv
|
| 41 |
+
|
| 42 |
+
# NOTE: We do NOT ignore *.h5 or *.keras here because you are using
|
| 43 |
+
# Git LFS to track them. If you were NOT using LFS, you would uncomment below:
|
| 44 |
+
# *.h5
|
| 45 |
+
# *.keras
|
| 46 |
+
|
| 47 |
+
# ========================
|
| 48 |
+
# ⚙️ IDE & OS FILES
|
| 49 |
+
# ========================
|
| 50 |
+
.DS_Store
|
| 51 |
+
Thumbs.db
|
| 52 |
+
.vscode/
|
| 53 |
+
.idea/
|
| 54 |
+
*.swp
|
| 55 |
+
|
| 56 |
+
# ========================
|
| 57 |
+
# 🐳 DOCKER
|
| 58 |
+
# ========================
|
| 59 |
+
# We usually keep the Dockerfile, but ignore local logs/mounts if any
|
| 60 |
+
docker-compose.override.yml
|
Dockerfile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 1. Use Python 3.10
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# 2. Set working directory
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# 3. Install system dependencies
|
| 8 |
+
RUN apt-get update && apt-get install -y libgl1 libglib2.0-0 && rm -rf /var/lib/apt/lists/*
|
| 9 |
+
|
| 10 |
+
# 4. Install Python dependencies
|
| 11 |
+
COPY requirements.txt .
|
| 12 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 13 |
+
|
| 14 |
+
# 5. Copy your code (and datasets) into the container
|
| 15 |
+
COPY . .
|
| 16 |
+
|
| 17 |
+
RUN python download_models.py
|
| 18 |
+
|
| 19 |
+
ENV PYTHONPATH=/app
|
| 20 |
+
|
| 21 |
+
# 6. Expose the port (5000 is standard for Flask)
|
| 22 |
+
EXPOSE 5000
|
| 23 |
+
|
| 24 |
+
# 7. Run the app
|
| 25 |
+
CMD ["python", "app/main.py"]
|
app/__init__.py
ADDED
|
File without changes
|
app/api/endpoints/facial.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Blueprint, request, jsonify
|
| 2 |
+
import cv2
|
| 3 |
+
import numpy as np
|
| 4 |
+
from app.services.emotion_engine import emotion_detector
|
| 5 |
+
|
| 6 |
+
# Create a Blueprint (a group of routes)
|
| 7 |
+
facial_bp = Blueprint('facial', __name__)
|
| 8 |
+
|
| 9 |
+
@facial_bp.route('/predict/emotion', methods=['POST'])
|
| 10 |
+
def predict_emotion():
|
| 11 |
+
"""
|
| 12 |
+
Endpoint to receive an image file and return the detected emotion.
|
| 13 |
+
Expects 'form-data' with a key named 'file'.
|
| 14 |
+
"""
|
| 15 |
+
if 'file' not in request.files:
|
| 16 |
+
return jsonify({"error": "No file part in the request"}), 400
|
| 17 |
+
|
| 18 |
+
file = request.files['file']
|
| 19 |
+
|
| 20 |
+
if file.filename == '':
|
| 21 |
+
return jsonify({"error": "No file selected"}), 400
|
| 22 |
+
|
| 23 |
+
try:
|
| 24 |
+
# Convert the uploaded file directly to a numpy array (OpenCV format)
|
| 25 |
+
# This avoids saving the file to disk, which is faster and cleaner.
|
| 26 |
+
file_bytes = np.frombuffer(file.read(), np.uint8)
|
| 27 |
+
image = cv2.imdecode(file_bytes, cv2.IMREAD_COLOR)
|
| 28 |
+
|
| 29 |
+
# Pass the image to our AI engine
|
| 30 |
+
result = emotion_detector.detect_emotion(image)
|
| 31 |
+
|
| 32 |
+
return jsonify(result)
|
| 33 |
+
|
| 34 |
+
except Exception as e:
|
| 35 |
+
return jsonify({"error": str(e)}), 500
|
app/api/endpoints/remedies.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Blueprint, request, jsonify
|
| 2 |
+
from app.services.remedy_engine import remedy_engine
|
| 3 |
+
|
| 4 |
+
remedies_bp = Blueprint('remedies', __name__)
|
| 5 |
+
|
| 6 |
+
@remedies_bp.route('/get_advice', methods=['GET'])
|
| 7 |
+
def get_advice():
|
| 8 |
+
"""
|
| 9 |
+
Query Param: ?condition=Depression
|
| 10 |
+
Returns: JSON with meds, treatments, and Gita story.
|
| 11 |
+
"""
|
| 12 |
+
condition = request.args.get('condition')
|
| 13 |
+
|
| 14 |
+
if not condition:
|
| 15 |
+
return jsonify({"error": "Missing 'condition' parameter"}), 400
|
| 16 |
+
|
| 17 |
+
result = remedy_engine.get_remedy(condition)
|
| 18 |
+
|
| 19 |
+
if result:
|
| 20 |
+
return jsonify(result)
|
| 21 |
+
else:
|
| 22 |
+
return jsonify({"message": "No specific remedy found for this condition."}), 404
|
app/api/endpoints/therapist.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Blueprint, request, jsonify
|
| 2 |
+
from app.services.llm_engine import llm_therapist
|
| 3 |
+
|
| 4 |
+
therapist_bp = Blueprint('therapist', __name__)
|
| 5 |
+
|
| 6 |
+
@therapist_bp.route('/chat', methods=['POST'])
|
| 7 |
+
def chat():
|
| 8 |
+
"""
|
| 9 |
+
Expects JSON:
|
| 10 |
+
{
|
| 11 |
+
"message": "I feel anxious",
|
| 12 |
+
"emotion": "fear",
|
| 13 |
+
"history": [
|
| 14 |
+
{"role": "user", "content": "Hi"},
|
| 15 |
+
{"role": "assistant", "content": "Hello!"}
|
| 16 |
+
]
|
| 17 |
+
}
|
| 18 |
+
"""
|
| 19 |
+
data = request.get_json()
|
| 20 |
+
|
| 21 |
+
user_message = data.get('message', '')
|
| 22 |
+
current_emotion = data.get('emotion', None)
|
| 23 |
+
history = data.get('history', [])
|
| 24 |
+
|
| 25 |
+
if not user_message:
|
| 26 |
+
return jsonify({"error": "Message cannot be empty"}), 400
|
| 27 |
+
|
| 28 |
+
# Generate response
|
| 29 |
+
response_text = llm_therapist.generate_response(user_message, current_emotion, history)
|
| 30 |
+
|
| 31 |
+
return jsonify({
|
| 32 |
+
"response": response_text
|
| 33 |
+
})
|
app/main.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from flask import Flask
|
| 3 |
+
from flask_cors import CORS
|
| 4 |
+
from dotenv import load_dotenv
|
| 5 |
+
|
| 6 |
+
# Load environment variables (API Keys) from .env
|
| 7 |
+
load_dotenv()
|
| 8 |
+
|
| 9 |
+
# Import the 3 Endpoints
|
| 10 |
+
from app.api.endpoints.facial import facial_bp
|
| 11 |
+
from app.api.endpoints.remedies import remedies_bp
|
| 12 |
+
from app.api.endpoints.therapist import therapist_bp
|
| 13 |
+
|
| 14 |
+
def create_app():
|
| 15 |
+
app = Flask(__name__)
|
| 16 |
+
|
| 17 |
+
# Enable CORS so Frontend (port 5173) can talk to Backend (port 5000)
|
| 18 |
+
CORS(app)
|
| 19 |
+
|
| 20 |
+
# Register the Blueprints (The 3 features)
|
| 21 |
+
app.register_blueprint(facial_bp, url_prefix='/api')
|
| 22 |
+
app.register_blueprint(remedies_bp, url_prefix='/api')
|
| 23 |
+
app.register_blueprint(therapist_bp, url_prefix='/api')
|
| 24 |
+
|
| 25 |
+
return app
|
| 26 |
+
|
| 27 |
+
if __name__ == '__main__':
|
| 28 |
+
app = create_app()
|
| 29 |
+
print("🚀 PsyPredict Backend is fully operational on http://localhost:5000")
|
| 30 |
+
print(" - /api/predict/emotion [POST]")
|
| 31 |
+
print(" - /api/get_advice?condition=... [GET]")
|
| 32 |
+
print(" - /api/chat [POST]")
|
| 33 |
+
app.run(host='0.0.0.0', port=5000, debug=True)
|
app/ml_assets/MEDICATION.csv
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Mental Condition,Symptoms,Recommended Treatments,Medications,Dosage,Advanced Remedies
|
| 2 |
+
Depression,sadness; loss of interest; fatigue; hopeless; worthlessness,Cognitive Behavioral Therapy (CBT); Exercise,Fluoxetine; Sertraline,20 mg daily; 50 mg daily,"""Imagine you are Arjuna standing in the middle of a battlefield, feeling confused and helpless. Lord Krishna told him: 'You must focus on doing your duty, not worry about what will happen next.' Similarly, when sadness feels overwhelming, focus on small actions like taking a walk or journaling. Step by step, your path becomes clearer."""
|
| 3 |
+
Anxiety,worry; restlessness; nervousness; panic; fear,Mindfulness; Deep Breathing Exercises,Buspirone; Clonazepam,10 mg twice daily; 0.5 mg twice daily,"""Think of your mind as a restless river that keeps rushing and never rests. Krishna said peace comes from steady action. Instead of trying to stop the river all at once, observe the flow calmly. Breathe deeply and tell yourself, 'It’s okay to feel nervous. I don’t have to control everything now.'"""
|
| 4 |
+
PTSD,flashbacks; nightmares; severe anxiety; trauma; dissociation,Trauma-Focused CBT; EMDR,Paroxetine; Sertraline,20 mg daily; 50 mg daily,"""Picture yourself as Arjuna who felt afraid of fighting his own family. Lord Krishna advised that facing fear is part of life. When painful memories come back, remind yourself they are passing shadows. Gently acknowledge them, knowing they will pass, and keep moving forward."""
|
| 5 |
+
Bipolar Disorder,mood swings; mania; depression; euphoria; impulsivity; irritability,Mood Stabilizers; CBT,Lithium; Valproate,300 mg daily; 500 mg twice daily,"""Life has highs and lows, like waves in the ocean. The Gita teaches focusing on steady actions without getting lost in emotions. Create daily routines and treat mood swings as temporary weather changes, not permanent states."""
|
| 6 |
+
Schizophrenia,hallucinations; delusions; disorganized thinking; paranoia; social withdrawal,Antipsychotic Medications; CBT,Risperidone; Olanzapine,2 mg daily; 10 mg daily,"""Schizophrenia may distort reality, but the Gita teaches our true self is beyond illusions. Therapy and medications stabilize perception, like dawn gradually clearing a misty morning."""
|
| 7 |
+
OCD,intrusive thoughts; repetitive behaviors; compulsions; rituals; anxiety-driven actions,CBT (Exposure and Response Prevention); Medication,Fluoxetine; Sertraline,20 mg daily; 50 mg daily,"""OCD feels like being trapped in a loop. The Gita teaches observing thoughts without reacting. Like clouds passing in the sky, they come and go. Mindfulness helps you understand they don’t define you."""
|
| 8 |
+
ADHD,inattention; hyperactivity; impulsivity; difficulty focusing; forgetfulness,Behavioral Therapy; Medication,Methylphenidate; Atomoxetine,10 mg daily; 40 mg daily,"""ADHD makes focusing hard. Krishna teaches purpose-driven action. Set small goals, focus on one thing at a time, and remind yourself: 'Every small task I do is a step toward my goal,' helping you build structure."""
|
| 9 |
+
Borderline Personality Disorder,intense emotions; unstable relationships; self-harm; fear of abandonment; impulsivity,Dialectical Behavior Therapy (DBT); Medication,Lamotrigine; Aripiprazole,100 mg daily; 10 mg daily,"""Feelings rise and fall like waves. The Gita suggests watching them without acting. Like a calm observer, you’ll see emotions pass without dragging you."""
|
| 10 |
+
Eating Disorders,disordered eating; preoccupation with weight; binge eating; purging; extreme dieting,Nutritional Counseling; CBT,Fluoxetine; Olanzapine,20 mg daily; 10 mg daily,"""Eating disorders come from a distorted self-image. The Gita reminds us our worth comes from inner values, not appearance. Care for your body gently, like tending a garden."""
|
| 11 |
+
Self-esteem Issues,low self-worth; negative self-image; inferiority; self-doubt,CBT; Motivational Interviewing,Sertraline; Escitalopram,50 mg daily; 10 mg daily,"""Self-esteem grows when you realize your worth lies in trying your best, not perfection. The Gita teaches to focus on effort as your true achievement."""
|
| 12 |
+
Social Anxiety Disorder,fear of social situations; avoidance; embarrassment; self-consciousness,CBT; Social Skills Training,Paroxetine; Clonazepam,20 mg daily; 0.5 mg twice daily,"""Social anxiety makes interaction hard. Krishna says focus on duty, not judgment. Start with small conversations, and remind yourself: 'Each small step is progress.'"""
|
| 13 |
+
Generalized Anxiety Disorder,excessive worry; muscle tension; restlessness; difficulty concentrating,CBT; Medication,Buspirone; Clonazepam,10 mg twice daily; 0.5 mg twice daily,"""Generalized anxiety makes you worry about everything. The Gita teaches handling what you can now and letting go of tomorrow's fears."""
|
| 14 |
+
Panic Disorder,panic attacks; dizziness; heart palpitations; shortness of breath,CBT; Exposure Therapy,Paroxetine; Sertraline,20 mg daily; 50 mg daily,"""Panic feels like a storm. The Gita says observe it calmly. Breathe deeply and remember: this storm will pass."""
|
| 15 |
+
Obsessive-Compulsive Personality Disorder,perfectionism; control; orderliness; rigidity,CBT; Behavioral Therapy,Fluoxetine; Clomipramine,20 mg daily; 25 mg daily,"""Perfection is impossible. The Gita teaches adaptability. Do your best, and let go of impossible standards."""
|
| 16 |
+
Substance Use Disorder,substance abuse; dependency; withdrawal; cravings; tolerance,Behavioral Therapy; Medication,Naltrexone; Methadone,50 mg daily; 30 mg daily,"""True freedom comes from letting go of harmful habits. The Gita teaches replacing unhealthy attachments with positive ones."""
|
| 17 |
+
Autism Spectrum Disorder,social difficulties; restricted interests; repetitive behaviors; communication challenges,Supportive Therapy; Occupational Therapy,Risperidone; Aripiprazole,2 mg daily; 10 mg daily,"""Autism makes social situations confusing. The Gita teaches compassion and patience. Your unique path is valuable."""
|
| 18 |
+
Dissociative Identity Disorder,multiple personalities; memory gaps; dissociation; identity confusion,Psychotherapy; Medication,Fluoxetine; Sertraline,20 mg daily; 50 mg daily,"""Your core self is stable. Therapy helps integrate fragmented parts, showing that every identity is a piece of the whole."""
|
| 19 |
+
Grief,sorrow; loss; mourning; sadness; emptiness,Supportive Counseling; Grief Therapy,None Typically,None Typically,"""Grief is part of life’s cycle. The Gita teaches acceptance and meaningful action, gently helping you heal over time."""
|
| 20 |
+
Seasonal Affective Disorder,depression in winter; lack of sunlight; fatigue; low mood during winter,Light Therapy; CBT,Fluoxetine; Bupropion,20 mg daily; 150 mg daily,"""Winter feels long and dark, but like light eventually shines, the Gita teaches hope and steady small actions through dark times."""
|
| 21 |
+
Insomnia,difficulty sleeping; waking at night; restlessness; trouble falling asleep,CBT-I; Sleep Hygiene Practices,Trazodone; Zolpidem,50 mg at night; 10 mg at night,"""Sleep comes when you stop chasing it. The Gita teaches calming the mind through routine and breathing."""
|
| 22 |
+
Intermittent Explosive Disorder,anger outbursts; aggression; irritability; uncontrollable rage,DBT; Medication,Lamotrigine; Risperidone,100 mg daily; 2 mg daily,"""Anger is like a passing cloud. Observe it without judgment, and it will fade."""
|
| 23 |
+
Trichotillomania,pulling out hair; hair loss; compulsive behavior; hair-pulling urges,Habit Reversal Therapy; Behavioral Therapy,None Typically,None Typically,"""Urges are temporary. Watch them like clouds in the sky. They pass."""
|
| 24 |
+
Dermatillomania,skin picking; skin lesions; compulsive behavior; skin damage,Behavioral Therapy; Medication,Fluoxetine; Sertraline,20 mg daily; 50 mg daily,"""See the urge to pick as a passing thought, not a command. Gently let it pass."""
|
| 25 |
+
Somatic Symptom Disorder,physical symptoms; excessive focus on health; distress; preoccupation with symptoms,CBT; Supportive Counseling,None Typically,None Typically,"""Focus on real duties and gentle self-care. Symptoms will fade like shadows."""
|
| 26 |
+
Conversion Disorder,neurological symptoms; paralysis; unexplained symptoms; loss of motor function,Psychotherapy; Physical Therapy,None Typically,None Typically,"""Trust your body’s ability to heal. Calm your mind and therapy will help."""
|
| 27 |
+
Factitious Disorder,faking illness; deception; symptom fabrication; self-induced symptoms,Psychotherapy; Medication,None Typically,None Typically,"""Be honest with yourself. Real healing comes from facing truth, not fabricating pain."""
|
| 28 |
+
Malingering,falsifying symptoms; external incentives; deceitful behavior; feigned illness,Psychotherapy; Supportive Counseling,None Typically,None Typically,"""True progress comes from aligning actions with inner truth."""
|
| 29 |
+
Acute Stress Disorder,dissociation; intrusive memories; anxiety after trauma; emotional numbness,Trauma-Focused CBT; EMDR,Paroxetine; Sertraline,20 mg daily; 50 mg daily,"""Suffering is temporary. Like a flowing river, let each moment pass without holding on."""
|
| 30 |
+
Schizoaffective Disorder,schizophrenia symptoms; mood disorder symptoms; psychosis; emotional instability,Medication; CBT,Risperidone; Lithium,2 mg daily; 300 mg daily,"""Balance is key. Focus on daily small actions, supported by therapy and medicine."""
|
| 31 |
+
Premenstrual Dysphoric Disorder,severe PMS; mood swings before menstruation; irritability; sadness,CBT; Lifestyle Changes,Fluoxetine; Sertraline,20 mg daily; 50 mg daily,"""Accept the cycle of life. Each phase is temporary. Self-care and compassion help you through."""
|
| 32 |
+
Adjustment Disorders,emotional symptoms; behavioral symptoms; difficulty coping,Psychotherapy; Supportive Counseling,None Typically,None Typically,"""Life is change. Like Arjuna adjusted in battle, take small steady steps to adapt."""
|
| 33 |
+
Burnout,exhaustion; cynicism; reduced efficacy; emotional depletion,CBT; Mindfulness,None Typically,None Typically,"""Balance effort with rest. Every small meaningful action helps rebuild energy."""
|
| 34 |
+
Internet Addiction,compulsive internet use; neglecting responsibilities; social withdrawal,Behavioral Therapy; Mindfulness,None Typically,None Typically,"""Digital interaction is temporary. Real connection grows slowly, step by step."""
|
| 35 |
+
Phone Addiction,excessive phone use; neglecting real interactions; constant checking,Mindfulness; Behavioral Therapy,None Typically,None Typically,"""Like Krishna teaches, presence matters more than constant connection. Start small."""
|
| 36 |
+
Loneliness,feeling isolated; lack of companionship; disconnected; longing,Psychotherapy; Social Skills Training,None Typically,None Typically,"""Your true self is always connected to the universe. Small acts of kindness rebuild connection."""
|
| 37 |
+
Hopelessness,sense of despair; lack of motivation; bleak future; giving up,CBT; Supportive Therapy,None Typically,None Typically,"""Each small step you take plants a seed of hope. Even slow progress matters."""
|
| 38 |
+
Anger Management Issues,anger outbursts; difficulty controlling temper; aggression; frustration,DBT; Psychotherapy,Lamotrigine; Risperidone,100 mg daily; 2 mg daily,"""Observe anger like clouds passing. Let it drift without acting."""
|
| 39 |
+
Perfectionism,fear of failure; high self-standards; overcritical self-evaluation; procrastination,CBT; Mindfulness,None Typically,None Typically,"""Perfect is a myth. Focus on doing your best, one step at a time."""
|
| 40 |
+
Chronic Pain Disorder,persistent pain; physical suffering; limited functionality,CBT; Physical Therapy,None Typically,None Typically,"""Pain is part of life. Like a warrior marching steadily, small self-care steps help."""
|
| 41 |
+
Emotional Instability,mood swings; difficulty maintaining relationships; sensitivity to criticism,Psychotherapy; Mindfulness,None Typically,None Typically,"""Emotions come and go. Like waves in the ocean, steady practices help balance them."""
|
| 42 |
+
Relationship Issues,communication problems; conflict; lack of intimacy; emotional distance,Couples Therapy; Supportive Counseling,None Typically,None Typically,"""See others with patience and compassion. Every small understanding builds connection."""
|
| 43 |
+
Workplace Stress,overwhelm; tight deadlines; lack of support; dissatisfaction,CBT; Mindfulness,None Typically,None Typically,"""Focus on your duty, not recognition. Calm steps reduce pressure."""
|
| 44 |
+
Financial Anxiety,money worries; fear of insolvency; budget concerns; debt anxiety,CBT; Financial Counseling,None Typically,None Typically,"""Krishna teaches responsibility without attachment. Budget calmly and steadily."""
|
| 45 |
+
Parenting Stress,guilt; overwhelm; lack of confidence; relationship strain,Supportive Counseling; Psychoeducation,None Typically,None Typically,"""Parenting is a sacred duty done with love and patience. Perfection isn’t the goal."""
|
| 46 |
+
Chronic Fatigue Syndrome,persistent tiredness; low energy; difficulty concentrating; sleep disturbances,CBT; Lifestyle Changes,None Typically,None Typically,"""Accept limits kindly. Every small progress is a victory."""
|
| 47 |
+
Existential Crisis,meaninglessness; questioning purpose; identity confusion; fear of death,Psychotherapy; Mindfulness,None Typically,None Typically,"""Life’s purpose is found in small selfless actions, not big answers."""
|
app/ml_assets/emotion_model_trained.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:321afafe98e32c9cf098c691e54000cf9c77f62203a2854829a128c081bcbe21
|
| 3 |
+
size 190595136
|
app/ml_assets/emotion_model_trained.keras
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a5501fcfd57d06acc45de397c55becb4fe3e317ab7c17b40d6d1273547567397
|
| 3 |
+
size 190584874
|
app/ml_assets/haarcascade_frontalface_default.xml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
app/services/emotion_engine.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import cv2
|
| 3 |
+
import numpy as np
|
| 4 |
+
import logging
|
| 5 |
+
from tensorflow.keras.models import load_model
|
| 6 |
+
from tensorflow.keras.preprocessing.image import img_to_array
|
| 7 |
+
|
| 8 |
+
# Define the exact labels from your notebook
|
| 9 |
+
EMOTION_LABELS = ['happy', 'sad', 'angry', 'surprised', 'neutral', 'fear', 'disgust']
|
| 10 |
+
|
| 11 |
+
class EmotionDetector:
|
| 12 |
+
def __init__(self):
|
| 13 |
+
self.model = None
|
| 14 |
+
self.face_cascade = None
|
| 15 |
+
self.load_resources()
|
| 16 |
+
|
| 17 |
+
def load_resources(self):
|
| 18 |
+
"""Loads the ML model and Haar Cascade from the assets folder."""
|
| 19 |
+
# Dynamic path to ensure it works on any machine
|
| 20 |
+
base_path = os.path.dirname(os.path.abspath(__file__))
|
| 21 |
+
assets_path = os.path.join(base_path, '..', 'ml_assets')
|
| 22 |
+
|
| 23 |
+
model_path = os.path.join(assets_path, 'emotion_model_trained.h5')
|
| 24 |
+
haar_path = os.path.join(assets_path, 'haarcascade_frontalface_default.xml')
|
| 25 |
+
|
| 26 |
+
# Load Model
|
| 27 |
+
try:
|
| 28 |
+
self.model = load_model(model_path)
|
| 29 |
+
logging.info(f"✅ Emotion Model loaded from {model_path}")
|
| 30 |
+
except Exception as e:
|
| 31 |
+
logging.error(f"❌ Failed to load model: {e}")
|
| 32 |
+
|
| 33 |
+
# Load Face Detector
|
| 34 |
+
try:
|
| 35 |
+
self.face_cascade = cv2.CascadeClassifier(haar_path)
|
| 36 |
+
if self.face_cascade.empty():
|
| 37 |
+
raise IOError("Failed to load Haarcascade XML file")
|
| 38 |
+
logging.info(f"✅ Face Detector loaded from {haar_path}")
|
| 39 |
+
except Exception as e:
|
| 40 |
+
logging.error(f"❌ Failed to load Haarcascade: {e}")
|
| 41 |
+
|
| 42 |
+
def detect_emotion(self, image_path_or_array):
|
| 43 |
+
"""
|
| 44 |
+
Input: Image (numpy array or file path)
|
| 45 |
+
Output: Dictionary with 'emotion' and 'confidence'
|
| 46 |
+
"""
|
| 47 |
+
if self.model is None or self.face_cascade is None:
|
| 48 |
+
return {"error": "AI models are not loaded"}
|
| 49 |
+
|
| 50 |
+
# 1. Read Image
|
| 51 |
+
if isinstance(image_path_or_array, str):
|
| 52 |
+
image = cv2.imread(image_path_or_array)
|
| 53 |
+
else:
|
| 54 |
+
image = image_path_or_array
|
| 55 |
+
|
| 56 |
+
if image is None:
|
| 57 |
+
return {"error": "Invalid image input"}
|
| 58 |
+
|
| 59 |
+
# 2. Convert to Grayscale
|
| 60 |
+
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
| 61 |
+
|
| 62 |
+
# 3. Detect Face
|
| 63 |
+
faces = self.face_cascade.detectMultiScale(gray, scaleFactor=1.3, minNeighbors=5)
|
| 64 |
+
|
| 65 |
+
if len(faces) == 0:
|
| 66 |
+
return {"message": "No face detected"}
|
| 67 |
+
|
| 68 |
+
# 4. Process the first detected face
|
| 69 |
+
(x, y, w, h) = faces[0]
|
| 70 |
+
roi_gray = gray[y:y+h, x:x+w]
|
| 71 |
+
|
| 72 |
+
# 5. Preprocessing (Resize to 48x48 & Normalize)
|
| 73 |
+
roi = cv2.resize(roi_gray, (48, 48), interpolation=cv2.INTER_AREA)
|
| 74 |
+
roi = roi.astype("float") / 255.0
|
| 75 |
+
roi = img_to_array(roi)
|
| 76 |
+
roi = np.expand_dims(roi, axis=0)
|
| 77 |
+
|
| 78 |
+
# 6. Predict
|
| 79 |
+
preds = self.model.predict(roi)[0]
|
| 80 |
+
label_index = preds.argmax()
|
| 81 |
+
label = EMOTION_LABELS[label_index]
|
| 82 |
+
confidence = float(preds[label_index])
|
| 83 |
+
|
| 84 |
+
return {
|
| 85 |
+
"emotion": label,
|
| 86 |
+
"confidence": round(confidence * 100, 2),
|
| 87 |
+
"face_box": [int(x), int(y), int(w), int(h)]
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
# Create a singleton instance to be imported elsewhere
|
| 91 |
+
emotion_detector = EmotionDetector()
|
app/services/llm_engine.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import google.generativeai as genai
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
|
| 5 |
+
# Load environment variables (API Keys)
|
| 6 |
+
load_dotenv()
|
| 7 |
+
|
| 8 |
+
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
|
| 9 |
+
|
| 10 |
+
if not GOOGLE_API_KEY:
|
| 11 |
+
print("⚠️ Error: GOOGLE_API_KEY not found. Check your .env file!")
|
| 12 |
+
else:
|
| 13 |
+
print("✅ Key loaded securely.")
|
| 14 |
+
|
| 15 |
+
class LLMEngine:
|
| 16 |
+
def __init__(self):
|
| 17 |
+
self.api_key = os.getenv("GOOGLE_API_KEY")
|
| 18 |
+
self.model = None
|
| 19 |
+
self._setup_model()
|
| 20 |
+
|
| 21 |
+
def _setup_model(self):
|
| 22 |
+
"""Configures the Gemini Model."""
|
| 23 |
+
if not self.api_key:
|
| 24 |
+
print("⚠️ WARNING: GOOGLE_API_KEY not found in .env file. Chat will function in 'Mock Mode'.")
|
| 25 |
+
return
|
| 26 |
+
|
| 27 |
+
try:
|
| 28 |
+
genai.configure(api_key=self.api_key)
|
| 29 |
+
self.model = genai.GenerativeModel('gemini-2.0-flash')
|
| 30 |
+
print("✅ LLM Engine: Gemini 2.0 Flash Connected")
|
| 31 |
+
except Exception as e:
|
| 32 |
+
print(f"❌ LLM Engine Error: {e}")
|
| 33 |
+
|
| 34 |
+
def generate_response(self, user_text, emotion_context=None, history=[]):
|
| 35 |
+
"""
|
| 36 |
+
Generates a therapeutic response.
|
| 37 |
+
|
| 38 |
+
Args:
|
| 39 |
+
user_text (str): The user's message.
|
| 40 |
+
emotion_context (str): The emotion detected by the camera (e.g., 'sad', 'happy').
|
| 41 |
+
history (list): Previous chat messages for context.
|
| 42 |
+
"""
|
| 43 |
+
|
| 44 |
+
# 1. Fallback if no API Key (Mock Mode)
|
| 45 |
+
if not self.model:
|
| 46 |
+
return "I am currently running in offline mode. Please set your GOOGLE_API_KEY to chat with me fully! (Detected emotion: " + str(emotion_context) + ")"
|
| 47 |
+
|
| 48 |
+
# 2. Construct the "System Prompt" (The Persona)
|
| 49 |
+
system_instruction = (
|
| 50 |
+
"You are PsyPredict, a compassionate, culturally grounded mental health assistant. "
|
| 51 |
+
"Your goal is to provide supportive, non-prescriptive guidance combining modern psychology "
|
| 52 |
+
"and wisdom from the Bhagavad Gita.\n\n"
|
| 53 |
+
"GUIDELINES:\n"
|
| 54 |
+
"1. Be empathetic and warm.\n"
|
| 55 |
+
"2. If the user seems stressed or sad, offer a short, relevant quote or metaphor from the Bhagavad Gita.\n"
|
| 56 |
+
"3. IMPORTANT: You are NOT a doctor. Do not diagnose or prescribe medication. If the user mentions self-harm, immediately provide emergency resources.\n"
|
| 57 |
+
"4. Keep responses concise (under 100 words) unless asked for a story."
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
# 3. Add "Fusion" Context (Visual + Text)
|
| 61 |
+
fusion_context = ""
|
| 62 |
+
if emotion_context and emotion_context != "neutral":
|
| 63 |
+
fusion_context = f"[SYSTEM NOTE: The user's facial expression currently shows '{emotion_context}'. Use this to adjust your tone.]\n"
|
| 64 |
+
|
| 65 |
+
# 4. Build the Full Prompt
|
| 66 |
+
# We combine history into a text block for simplicity (stateless request)
|
| 67 |
+
conversation_log = "\n".join([f"{msg['role']}: {msg['content']}" for msg in history[-5:]]) # Keep last 5 turns
|
| 68 |
+
|
| 69 |
+
final_prompt = f"{system_instruction}\n\nCONVERSATION HISTORY:\n{conversation_log}\n\n{fusion_context}User: {user_text}\nAssistant:"
|
| 70 |
+
|
| 71 |
+
try:
|
| 72 |
+
# 5. Call Gemini
|
| 73 |
+
response = self.model.generate_content(final_prompt)
|
| 74 |
+
return response.text.strip()
|
| 75 |
+
except Exception as e:
|
| 76 |
+
return f"I'm having trouble connecting to my thought engine right now. Error: {str(e)}"
|
| 77 |
+
|
| 78 |
+
# Singleton Instance
|
| 79 |
+
llm_therapist = LLMEngine()
|
app/services/remedy_engine.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
class RemedyEngine:
|
| 5 |
+
def __init__(self):
|
| 6 |
+
self.df = None
|
| 7 |
+
self.load_data()
|
| 8 |
+
|
| 9 |
+
def load_data(self):
|
| 10 |
+
"""Loads the MEDICATION.csv file into a Pandas DataFrame."""
|
| 11 |
+
try:
|
| 12 |
+
base_path = os.path.dirname(os.path.abspath(__file__))
|
| 13 |
+
csv_path = os.path.join(base_path, '..', 'ml_assets', 'MEDICATION.csv')
|
| 14 |
+
|
| 15 |
+
if os.path.exists(csv_path):
|
| 16 |
+
self.df = pd.read_csv(csv_path)
|
| 17 |
+
# Normalize column names to be safe
|
| 18 |
+
self.df.columns = [c.strip() for c in self.df.columns]
|
| 19 |
+
print("✅ Remedy Engine: Knowledge Base Loaded")
|
| 20 |
+
else:
|
| 21 |
+
print(f"❌ Remedy Engine: CSV not found at {csv_path}")
|
| 22 |
+
except Exception as e:
|
| 23 |
+
print(f"❌ Remedy Engine Error: {e}")
|
| 24 |
+
|
| 25 |
+
def get_remedy(self, condition_name):
|
| 26 |
+
"""
|
| 27 |
+
Searches for a condition (e.g., 'Depression') and returns the full remedy details.
|
| 28 |
+
It uses case-insensitive partial matching.
|
| 29 |
+
"""
|
| 30 |
+
if self.df is None:
|
| 31 |
+
return {"error": "Database not loaded"}
|
| 32 |
+
|
| 33 |
+
# Search for the condition (case-insensitive)
|
| 34 |
+
# We check if the search term is IN the 'Mental Condition' column
|
| 35 |
+
mask = self.df['Mental Condition'].str.contains(condition_name, case=False, na=False)
|
| 36 |
+
result = self.df[mask]
|
| 37 |
+
|
| 38 |
+
if result.empty:
|
| 39 |
+
return None
|
| 40 |
+
|
| 41 |
+
# Get the first match
|
| 42 |
+
row = result.iloc[0]
|
| 43 |
+
|
| 44 |
+
return {
|
| 45 |
+
"condition": row['Mental Condition'],
|
| 46 |
+
"symptoms": row['Symptoms'],
|
| 47 |
+
"treatments": row['Recommended Treatments'],
|
| 48 |
+
"medications": row['Medications'],
|
| 49 |
+
"dosage": row['Dosage'],
|
| 50 |
+
"gita_remedy": row['Advanced Remedies'] # This is the story/advice
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
# Singleton instance
|
| 54 |
+
remedy_engine = RemedyEngine()
|
download_models.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import gdown # We will install this library
|
| 3 |
+
|
| 4 |
+
# 👇 PASTE YOUR GOOGLE DRIVE IDs HERE
|
| 5 |
+
MODEL_ID = "10GWSogJNKlPlTeWtJkDq_zc4roB1Vmnu"
|
| 6 |
+
CSV_ID = "1bJ8C1BY0rvPNKuWcBgqiUtiSzHziZokH"
|
| 7 |
+
|
| 8 |
+
# Define where they should go
|
| 9 |
+
model_path = "app/ml_assets/emotion_model_trained.h5"
|
| 10 |
+
csv_path = "app/ml_assets/MEDICATION.csv"
|
| 11 |
+
|
| 12 |
+
def download_file(file_id, output_path):
|
| 13 |
+
if not os.path.exists(output_path):
|
| 14 |
+
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
| 15 |
+
url = f'https://drive.google.com/uc?id={file_id}'
|
| 16 |
+
print(f"⬇️ Downloading {output_path}...")
|
| 17 |
+
gdown.download(url, output_path, quiet=False)
|
| 18 |
+
else:
|
| 19 |
+
print(f"✅ Found {output_path}, skipping download.")
|
| 20 |
+
|
| 21 |
+
if __name__ == "__main__":
|
| 22 |
+
print("🚀 Starting Model Download...")
|
| 23 |
+
download_file(MODEL_ID, model_path)
|
| 24 |
+
download_file(CSV_ID, csv_path)
|
| 25 |
+
print("✅ All models ready!")
|
requirements.txt
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# --- Core Backend ---
|
| 2 |
+
flask
|
| 3 |
+
flask-cors
|
| 4 |
+
python-dotenv
|
| 5 |
+
google-generativeai
|
| 6 |
+
gdown
|
| 7 |
+
|
| 8 |
+
# --- AI & Vision (Version Locked for Stability) ---
|
| 9 |
+
numpy<2.0
|
| 10 |
+
opencv-python
|
| 11 |
+
tensorflow
|
| 12 |
+
pandas
|
| 13 |
+
tensorflow-cpu
|
| 14 |
+
pillow
|
| 15 |
+
|
| 16 |
+
# --- Utilities ---
|
| 17 |
+
requests
|