Loading repository data…
Loading repository data…
Hamna-Munir / repository
MoodGuard is an AI-powered mood detection and mental health monitoring web app that analyzes facial expressions and images in real time using Flask, Deep Learning, TensorFlow, and OpenCV with a privacy-first approach.
Real-time emotion detection powered by deep learning and computer vision — analyze facial expressions through photos or live webcam using AI.
MoodGuard is an AI-powered emotion recognition and mental health monitoring web application that uses Convolutional Neural Networks (CNN) and computer vision to detect facial emotions in real time.
The system can analyze uploaded images, captured photos, and live webcam feeds to predict emotional states such as happiness, sadness, anger, fear, surprise, disgust, and neutrality.
It is designed with a privacy-first local AI approach, meaning no facial data is sent to any external server.
| Metric | Value |
|---|---|
| 🎯 Model Accuracy | 66.6% |
| 🖼️ Training Images | 35,000+ |
| 😄 Emotion Classes | 7 |
| 🧠 Model Type | CNN |
| 📦 Dataset | FER2013 |
| 🔒 Privacy | 100% Local Processing |
Upload facial images and instantly detect emotional state with AI-powered prediction.
Real-time emotion detection through webcam feed.
Clean and interactive dashboard UI built with HTML, CSS, and JavaScript.
Can track and display previous analysis sessions.
All processing happens locally. No cloud upload. No external APIs.
TensorFlow model loaded directly in Flask for fast prediction.
CNN trained on FER2013 facial expression dataset.
| Technology | Role |
|---|---|
| 🐍 Python 3.10 | Core language |
| 🌐 Flask | Backend web framework |
| 🤖 TensorFlow / Keras | CNN model loading & prediction |
| 📷 OpenCV | Face detection & image preprocessing |
| 🔢 NumPy | Numerical computation |
| 🖼️ Pillow | Image handling |
| 🎨 HTML / CSS / JS | Frontend dashboard |
| 📦 H5Py | Loading .h5 trained model |
moodguard_model.h5git clone https://github.com/yourusername/MoodGuard.git
cd MoodGuard
python -m venv venv
venv\Scripts\activate
source venv/bin/activate
pip install -r requirements.txt
Place:
moodguard_model.h5
inside project root directory.
python app.py
Open browser:
http://127.0.0.1:5000
Flask==3.0.3
tensorflow==2.10.0
opencv-python==4.10.0.84
numpy==1.23.5
Pillow==10.4.0
h5py==3.11.0
gunicorn==22.0.0
Install:
pip install -r requirements.txt
Input Image / Webcam
│
▼
┌────────────────────────┐
│ 1. Image Capture │
│ Photo Upload / Webcam │
└────────────┬───────────┘
│
▼
┌────────────────────────┐
│ 2. Face Detection │
│ OpenCV Haar Cascade │
└────────────┬───────────┘
│
▼
┌────────────────────────┐
│ 3. Preprocessing │
│ Resize + Normalize │
└────────────┬───────────┘
│
▼
┌────────────────────────┐
│ 4. CNN Prediction │
│ TensorFlow / Keras │
└────────────┬───────────┘
│
▼
┌────────────────────────┐
│ 5. Emotion Output │
│ UI + Prediction Result │
└────────────────────────┘
MoodGuard detects 7 emotions:
| Property | Value |
|---|---|
| Model | CNN |
| Framework | TensorFlow / Keras |
| Dataset | FER2013 |
| Classes | 7 Emotions |
| Training Images | 35K+ |
| Format | .h5 |
| Input | Facial Expressions |
MoodGuard/
│
├── app.py
├── detect_emotion.py
├── prepare_dataset.py
├── train_model.py
├── moodguard_model.h5
├── requirements.txt
├── README.md
├── .gitignore
│
├── templates/
│ └── index.html
│
└── static/
├── style.css
└── script.js
| Section | Description |
|---|---|
| 📸 Photo Analysis | Upload image → detect emotion |
| 🎥 Video Detection | Real-time webcam prediction |
| 📜 History | Previous detections |
| ℹ️ About | System overview |
Place moodguard_model.h5 in root directory.
Check OS/browser camera permissions.
Use a clear front-facing image.
Close other heavy applications.
Use Python 3.10 (recommended).
Hamna Munir
AI/ML Engineer • Software Engineering Student
Built MoodGuard as an end-to-end AI project combining:
This project demonstrates a complete machine learning workflow from preprocessing → model training → deployment.
Licensed under MIT License.