An automated attendance tracking system powered by Deep Face Recognition and Streamlit. This project processes a dataset of student images to generate facial embeddings and later compares them against a classroom image to automatically mark attendance.
- Face Registration & Embeddings: Extracts facial features from student images using InsightFace (
buffalo_lmodel for detection and representation) and stores them as.pklembeddings. - Automated Attendance Marking: Analyzes uploaded classroom images, extracts faces, and matches them against stored student embeddings using Cosine Distance.
- Interactive Web Interface: A user-friendly Streamlit dashboard for:
- Generating and loading student datasets.
- Uploading multiple classroom images to continuously evaluate attendance.
- Viewing summarized Final Attendance reports with an option to download as a CSV.
- Previewing annotated classroom images (with bounding boxes and names directly drawn).
- Reviewing "Unknown" faces detected in the classroom.
- Python 3.8+
- The project dependencies listed in
requirements.txt.
-
Clone or download this repository.
-
Create and activate a Virtual Environment (Recommended):
python -m venv myenv source myenv/bin/activate # On Windows: myenv\Scripts\activate
-
Install the required dependencies:
pip install -r requirements.txt
- Tiled Face Detection: Splits large classroom images into overlapping tiles to improve detection of small or occluded faces (
buffalo_l). - Non-Maximum Suppression (NMS): Filters out duplicate bounding boxes generated at tile boundaries.
- Face Clustering: Groups faces based on embedding distances. Why it's useful: Helps remove unwanted matching anomalies by combining multiple angles of the same person into one robust identity, reducing false positives.
- Face Matching & Classification: Compares clustered embeddings against the known dataset. Strict calibration thresholds ensure unverified faces are marked as "Unknown".
For the system to recognize students, you need to structure your dataset inside the course_project_dataset folder. Create a subfolder for each student using their name, and place their face images (e.g., from different angles) inside.
Automated-Attendance-Management-System/
├── course_project_dataset/
│ ├── Alice/
│ │ ├── img1.jpg
│ │ ├── img2.jpg
│ ├── Bob/
│ │ ├── img1.jpg
│ │ ├── img2.jpg
│ └── ...
You can interact with the system entirely through the Streamlit App:
streamlit run app.py- System Setup: On the sidebar, click the "Load Dataset & Generate Embeddings" button. This will analyze the images in the
course_project_dataset/folder and generate the embeddings file (embeddings/embeddings_dl.pkl). Note: This may take some time depending on hardware speed and dataset size. - Evaluating Attendance: Upload up to 5 classroom images (in
.jpg,.jpeg, or.pngformat). - Process Images: Click "Process Images & Mark Attendance" to run the recognition pipeline.
- View Results: Check the tabs to see:
- Attendance Report: View and download the attendance CSV report (
Present/Absent). - Classroom Images: View annotated versions of your uploaded images.
- Unknown Faces: View cropped faces of people who weren't recognized.
- Attendance Report: View and download the attendance CSV report (
You can also bypass the Streamlit app to independently generate embeddings or process an image from the terminal:
- Generate Embeddings:
python generate_embeddings.py - Mark Attendance for a single image:
python mark_attendance.py <path_to_class_image.jpg>
app.py: The main Streamlit web application.generate_embeddings.py: Script dedicated to extracting faces from thecourse_project_datasetand generating mathematical embedding representations (stored in.pklformat).mark_attendance.py: Core logic for matching extracted faces from a classroom image strictly against the saved embeddings utilizing cosine-distance calculations.requirements.txt: Python package dependency list.embeddings/: Folder to store the generated embeddings.output/: Folder to save temporary output results like CSV files, annotated frames, and unknown face crops.uploads/: Folder used to store temporarily uploaded classroom images from Streamlit.