Skip to content

Repository files navigation

🎓 Smart Attendance and Emotion Recognition System

This project is a machine learning–based attendance system that detects and identifies students in real time using a webcam.
It automatically marks attendance and logs the detected emotion (happy, neutral, sad, etc.) along with the timestamp in a CSV file.
The system operates only between 9:30 AM and 10:00 AM to simulate a classroom environment.


✨ Features

  • 🧠 Face Recognition – Identifies registered students using a trained CNN model
  • 😊 Emotion Detection – Recognizes facial emotions using the FER dataset
  • Time Restriction – Works only during a scheduled window (9:30–10:00 AM)
  • 🌐 Web App Interface (Flask + OpenCV) – Stream live video and monitor recognition in real time
  • 📊 Attendance Logging – Automatically saves student name, emotion, and timestamp in CSV
  • 📁 On-Demand Export – Export attendance data via a single button click
  • 💾 Lightweight, Modular Design – Clean Python-based code, easy to reproduce

🧩 Project Structure

attendance_clean/ ├── web_app/ │ ├── core.py # Handles video feed, face & emotion detection logic │ └── flask_app.py # Flask server + web interface │ ├── scripts/ │ ├── train_faceid.py # Train face identification model │ ├── train_emotion.py # Train emotion classification model │ ├── dataset_audit.py # Inspect dataset distribution │ ├── augment_class.py # Perform image augmentation │ └── attendance_run.py # Optional: run attendance offline (CLI) │ ├── models/ │ ├── faceid_labels.json │ └── emotion_labels.json │ ├── utils.py ├── test_face_pred.py ├── test_emotion.py ├── evaluate_face_model.py ├── inspect_predictions.py ├── .gitignore ├── README.md └── requirements.txt


🚀 How to Run

1️⃣ Setup Environment

pip install -r requirements.txt


2️⃣ Run Web App
python web_app/flask_app.py
Then open your browser at:
http://127.0.0.1:5000
Click Start Stream to activate the camera.
The system will detect faces, emotions, and mark attendance automatically.
Click Export Attendance CSV to download the attendance report.

🧠 Model Information
FaceID Model – Trained on custom dataset under data/faceid/
Emotion Model – Trained on FER2013 dataset (fer2013.zip, not uploaded due to size limit)

To recreate models:
python scripts/train_faceid.py --data_dir data/faceid
python scripts/train_emotion.py --data_dir data/emotion
Model binaries (.h5) are excluded from this repository due to GitHub file size limits.

🕒 Time-Based Restriction
Attendance detection is automatically active only between 9:30 AM and 10:00 AM.
Outside this time window, the system won’t log attendance.

📊 Output Example
Name	Emotion	Time
Bushra	Happy	09:35:12 AM
Waniya	Neutral	09:42:05 AM
Zaid	Sad	09:50:33 AM

Exported automatically to:
exports/attendance_YYYYMMDD_HHMMSS.csv


🧩 Tech Stack
Python 3.12
Flask – Web server
OpenCV – Video stream and image processing
TensorFlow / Keras – Model inference
NumPy, Pandas – Data operations

About

A real-time AI-based attendance system that detects and identifies students using face recognition and emotion analysis. Built with Flask, OpenCV, and TensorFlow, it automatically marks attendance, detects emotions, and logs data in CSV format between 9:30–10:00 AM.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages