πΈ Face Recognition Login System (Django + DeepFace)
A simple facial recognition system using **Django + DeepFace + OpenCV**.
- Python 3.10 (IMPORTANT β)
- Windows 10/11
- Webcam
π Check Python Version
Note: Must be Python 3.10
Create Or Switch Virtual Environment
Activate Environment (Windows)
Install Required Libraries
pip install django deepface numpy
pip install opencv-python==4.9.0.80
π§ Install TensorFlow (IMPORTANT for DeepFace)
pip install tensorflow==2.15.0
π§ Install Keras (optional but safe)
pip install keras==2.15.0
pip install tf-keras
π Create Django Project
django-admin startproject config .
python manage.py startapp users
INSTALLED_APPS = [
...
'users',
]
python manage.py runserver
πΈ Face Recognition Flow
β’ Capture multiple images using webcam
β’ Save in:
β’ Capture image
β’ Compare using DeepFace
β’ Return match result
face_login/
β
βββ config/
βββ users/
βββ media/
β βββ faces/
βββ venv/
βββ manage.py
β MUST use Python 3.10 (3.11/3.13 may break TensorFlow/DeepFace)
β Good lighting improves accuracy
β Webcam must be accessible
β First DeepFace run may be slow (model download)
pip install --upgrade pip
β OpenCV camera not opening
β DeepFace slow first run
Normal (downloads AI models)
π€ 1. REGISTER (Save Face)
http://127.0.0.1:8000/users/register/?name=ricardo
1. Camera opens
2. You press:
β’ S = save image
β’ Q = quit
3. Images are saved here:
media/faces/ricardo/
0.jpg
1.jpg
2.jpg
User βricardoβ is now registered in the system.
π 2. LOGIN (Face Recognition)
http://127.0.0.1:8000/users/login/
1. Camera opens
2. Takes 1 snapshot
3. Saves temporary image:
β’ media/temp.jpg
4. DeepFace compares:
β’ temp.jpg vs all saved faces
{
"status": "success",
"user": "ricardo"
}
π 3. DELETE USER (Remove Face Data)
http://127.0.0.1:8000/users/delete/?name=yourname
Deletes folder:
media/faces/ricardo/
{
"status" : " deleted" ,
"user" : " ricardo"
}
{
"status" : " not found"
}
βοΈ SIMPLE FLOW SUMMARY
π€ REGISTER β save face images in folder
π LOGIN β compare camera face with saved faces
π DELETE β remove user folder
β οΈ IMPORTANT REMINDERS
β Always run server first:
β Always activate venv:
β Use good lighting for face detection
Real-time video recognition
Face embeddings (faster login)
Database instead of folders
Liveness detection (anti-photo spoofing)
HTML login UI
Name: Ricardo Jr Liera
Project: Face Recognition Login System
Stack: Django + DeepFace + OpenCV
Year: 2026