System Requirements
Operating System
- Linux (Ubuntu 20.04+)
- macOS (10.15+)
- Windows 10/11
Python
- Python 3.8 or higher
- pip package manager
- Virtual environment (recommended)
Hardware
- Webcam (for real-time detection)
- 4GB RAM minimum
- 1GB free disk space
Browser
- Chrome 80+
- Firefox 75+
- Safari 13+
- Edge 80+
Python Environment Setup
- Linux/macOS
- Windows
Create and activate a virtual environment:
You should see Python 3.8 or higher. If not, install a newer version using your package manager.
Install Dependencies
Core Requirements
Install all required packages fromrequirements.txt:
Key Dependencies
Therequirements.txt file includes:
Web Framework (Flask 3.1.3)
Web Framework (Flask 3.1.3)
Flask powers the web server and API endpoints:
Flask==3.1.3- Core frameworkWerkzeug==3.1.6- WSGI utilitiesJinja2==3.1.6- Template engineclick==8.3.1- CLI utilities
Computer Vision (OpenCV 4.13.0.92)
Computer Vision (OpenCV 4.13.0.92)
OpenCV handles all image processing and facial detection:
opencv-contrib-python==4.13.0.92- Required for cv2.face moduleopencv-python==4.13.0.92- Core OpenCV functionality
Machine Learning (scikit-learn 1.8.0)
Machine Learning (scikit-learn 1.8.0)
Scikit-learn provides the classification algorithms:
scikit-learn==1.8.0- Random Forest classifiernumpy==2.4.2- Numerical arraysscipy==1.17.1- Scientific computingjoblib==1.5.3- Model serialization
Google Gemini AI (Optional)
Google Gemini AI (Optional)
For AI-powered emotional analysis:
google-genai==1.66.0- Gemini API clientgoogle-auth==2.48.0- Authenticationhttpx==0.28.1- HTTP client
This is optional. Real-time emotion detection works without Gemini. Only session analysis requires it.
Visualization (matplotlib 3.10.8)
Visualization (matplotlib 3.10.8)
For data visualization during model training:
matplotlib==3.10.8- Plotting libraryPillow==12.1.1- Image processing
OpenCV Installation
Why opencv-contrib-python?
EmoChat uses the LBF (Local Binary Features) facial landmark model, which is part of OpenCV’scv2.face module. This module is only available in opencv-contrib-python.
Verify Installation
Check if cv2.face module is available:Fix Missing cv2.face Module
If you get an error aboutcv2.face not existing:
- Solution 1: Reinstall
- Solution 2: Build from Source
Google Gemini API Setup (Optional)
Get API Key
- Visit Google AI Studio
- Sign in with your Google account
- Click “Create API Key”
- Copy your API key
Model Files Download
EmoChat automatically downloads required model files on first run:Haar Cascade Classifier
File:
haarcascade_frontalface_default.xmlSource: OpenCV GitHub repositoryPurpose: Detects faces in imagesSize: ~900 KBLBF Landmark Model
File:
lbfmodel.yamlSource: GSOC2017 GitHub repositoryPurpose: Extracts 68 facial landmarksSize: ~50 MBThese models are downloaded automatically by
utils.py when you first run prepare_data.py, train_model.py, or app.py. No manual download required.Manual Download (Optional)
If automatic download fails, download manually:Verify Installation
Run this verification script:verify_install.py
Troubleshooting
Common Issues
ImportError: No module named 'cv2'
ImportError: No module named 'cv2'
OpenCV is not installed:
AttributeError: module 'cv2' has no attribute 'face'
AttributeError: module 'cv2' has no attribute 'face'
You have
opencv-python instead of opencv-contrib-python:ModuleNotFoundError: No module named 'flask'
ModuleNotFoundError: No module named 'flask'
Flask is not installed:
FileNotFoundError: No se encontró el modelo entrenado
FileNotFoundError: No se encontró el modelo entrenado
The model hasn’t been trained yet:
SSL/TLS Certificate Errors on Windows
SSL/TLS Certificate Errors on Windows
Windows may have certificate issues when downloading models:Or download models manually (see “Model Files Download” section).
Permission Denied on Linux/macOS
Permission Denied on Linux/macOS
Use
pip install --user or activate virtual environment:Port 5000 Already in Use
Port 5000 Already in Use
Change the port in
app.py:96:Platform-Specific Issues
- macOS
- Linux
- Windows
Webcam PermissionGrant Terminal/IDE camera access in System Preferences:M1/M2 ARM IssuesIf you encounter architecture errors:
Next Steps
Once installation is complete:Quickstart Guide
Follow the quickstart to train your model and launch EmoChat
Model Training
Learn how to prepare data and train the emotion classifier
API Reference
Explore Flask API endpoints and integration options
Core Concepts
Understand the system architecture and how components work together

