How jyotiska222/emotion-detection-model works
Project type and purpose
• This is a machine-learning / computer-vision project that trains a CNN on the FER-2013 dataset and then performs real-time emotion detection via a webcam feed.
• It’s an open-source tool for emotion recognition, consisting of a training pipeline, evaluation pipeline, saved model storage, and an inference (real-time) component.
File structure
• Top-level:
• dataset/ – raw images organized by emotion labels (train & test)
• saved_model/ – serialized Keras model (emotion_model.h5)
• src/ – Python scripts
• requirements.txt, README.md
• src/ contains three distinct scripts:
• train_model.py – loads dataset, defines and trains CNN, writes model to saved_model/
• test_model.py – loads saved_model/emotion_model.h5 and test images, reports metrics
• realtime_emotion.py – uses OpenCV to capture webcam frames, loads the model, preprocesses faces, predicts and renders label overlays
README for additional insights
• Confirms the use of TensorFlow/Keras, OpenCV, NumPy, Pandas, Matplotlib.
• Describes training → testing → real-time inference workflows.
a. Main components
• Data Storage
– FER-2013 dataset (dataset/train, dataset/test)
• Training Module
– train_model.py, CNN architecture, TensorFlow/Keras
• Model Repository
– saved_model/emotion_model.h5
• Evaluation Module
– test_model.py
• Inference Module
– realtime_emotion.py, OpenCV, webcam
• External Interfaces
– User’s webcam, display window
b. Relationships and interactions
1. Data Storage → Training Module (batch ingestion of training images)
2. Training Module → Model Repository (save trained .h5)
3. Data Storage → Evaluation Module & Model Repository → Evaluation Module (load test images & model, compute metrics)
4. Model Repository & External Interface (webcam) → Inference Module (load model, capture frames, predict, render)
c. Architectural patterns / design principles
• Separation of Concerns: distinct scripts for training, testing, inference
• Data-Model-Interface pipeline: raw data → model artifact → runtime inference
• Modularization: each major step is encapsulated in its own Python script
• Reproducibility: uses requirements.txt and consistent directory layout
d. Key technologies, frameworks, libraries
• TensorFlow / Keras – CNN definition, training, serialization
• OpenCV – face detection / capture, frame processing, display
• NumPy & Pandas – data handling and preprocessing
• Matplotlib – optional visualizations in train/test scripts